mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: stage instance invite (#5856)
Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
const Base = require('./Base');
|
||||
const IntegrationApplication = require('./IntegrationApplication');
|
||||
const InviteStageInstance = require('./InviteStageInstance');
|
||||
const { Error } = require('../errors');
|
||||
const { Endpoints } = require('../util/Constants');
|
||||
const Permissions = require('../util/Permissions');
|
||||
@@ -112,6 +113,15 @@ class Invite extends Base {
|
||||
this.createdTimestamp = 'created_at' in data ? new Date(data.created_at).getTime() : null;
|
||||
|
||||
this._expiresTimestamp = 'expires_at' in data ? new Date(data.expires_at).getTime() : null;
|
||||
|
||||
/**
|
||||
* The stage instance data if there is a public {@link StageInstance} in the stage channel this invite is for
|
||||
* @type {?InviteStageInstance}
|
||||
*/
|
||||
this.stageInstance =
|
||||
'stage_instance' in data
|
||||
? new InviteStageInstance(this.client, data.stage_instance, this.channel.id, this.guild.id)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
80
src/structures/InviteStageInstance.js
Normal file
80
src/structures/InviteStageInstance.js
Normal file
@@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
const Collection = require('../util/Collection');
|
||||
|
||||
/**
|
||||
* Represents the data about a public {@link StageInstance} in an {@link Invite}.
|
||||
* @extends {Base}
|
||||
*/
|
||||
class InviteStageInstance extends Base {
|
||||
constructor(client, data, channelID, guildID) {
|
||||
super(client);
|
||||
|
||||
/**
|
||||
* The ID of the stage channel this invite is for
|
||||
* @type {Snowflake}
|
||||
*/
|
||||
this.channelID = channelID;
|
||||
|
||||
/**
|
||||
* The guild ID of the stage channel
|
||||
* @type {Snowflake}
|
||||
*/
|
||||
this.guildID = guildID;
|
||||
|
||||
/**
|
||||
* The members speaking in the stage channel
|
||||
* @type {Collection<Snowflake, GuildMember>}
|
||||
*/
|
||||
this.members = new Collection();
|
||||
|
||||
this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* The topic of the stage instance
|
||||
* @type {string}
|
||||
*/
|
||||
this.topic = data.topic;
|
||||
|
||||
/**
|
||||
* The number of users in the stage channel
|
||||
* @type {number}
|
||||
*/
|
||||
this.participantCount = data.participant_count;
|
||||
|
||||
/**
|
||||
* The number of users speaking in the stage channel
|
||||
* @type {number}
|
||||
*/
|
||||
this.speakerCount = data.speaker_count;
|
||||
|
||||
this.members.clear();
|
||||
for (const rawMember of data.members) {
|
||||
const member = this.guild.members.add(rawMember);
|
||||
this.members.set(member.id, member);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The stage channel this invite is for
|
||||
* @type {?StageChannel}
|
||||
* @readonly
|
||||
*/
|
||||
get channel() {
|
||||
return this.client.channels.resolve(this.channelID);
|
||||
}
|
||||
|
||||
/**
|
||||
* The guild of the stage channel this invite is for
|
||||
* @type {?Guild}
|
||||
* @readonly
|
||||
*/
|
||||
get guild() {
|
||||
return this.client.guilds.resolve(this.guildID);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = InviteStageInstance;
|
||||
13
typings/index.d.ts
vendored
13
typings/index.d.ts
vendored
@@ -1192,6 +1192,19 @@ declare module 'discord.js' {
|
||||
public toJSON(): unknown;
|
||||
public toString(): string;
|
||||
public static INVITES_PATTERN: RegExp;
|
||||
public stageInstance: InviteStageInstance | null;
|
||||
}
|
||||
|
||||
export class InviteStageInstance extends Base {
|
||||
constructor(client: Client, data: unknown, channelID: Snowflake, guildID: Snowflake);
|
||||
public channelID: Snowflake;
|
||||
public guildID: Snowflake;
|
||||
public members: Collection<Snowflake, GuildMember>;
|
||||
public topic: string;
|
||||
public participantCount: number;
|
||||
public speakerCount: number;
|
||||
public readonly channel: StageChannel | null;
|
||||
public readonly guild: Guild | null;
|
||||
}
|
||||
|
||||
export class Message extends Base {
|
||||
|
||||
Reference in New Issue
Block a user