Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
- Loading branch information
1 parent
a3cbcca
commit 2d12db0
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters