/
StageChannel.js
70 lines (62 loc) · 2.07 KB
/
StageChannel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict';
const BaseGuildVoiceChannel = require('./BaseGuildVoiceChannel');
/**
* Represents a guild stage channel on Discord.
* @extends {BaseGuildVoiceChannel}
*/
class StageChannel extends BaseGuildVoiceChannel {
_patch(data) {
super._patch(data);
if ('topic' in data) {
/**
* The topic of the stage channel
* @type {?string}
*/
this.topic = data.topic;
}
}
/**
* The stage instance of this stage channel, if it exists
* @type {?StageInstance}
* @readonly
*/
get stageInstance() {
return this.guild.stageInstances.cache.find(stageInstance => stageInstance.channelId === this.id) ?? null;
}
/**
* Creates a stage instance associated with this stage channel.
* @param {StageInstanceCreateOptions} options The options to create the stage instance
* @returns {Promise<StageInstance>}
*/
createStageInstance(options) {
return this.guild.stageInstances.create(this.id, options);
}
/**
* Sets a new topic for the guild channel.
* @param {?string} topic The new topic for the guild channel
* @param {string} [reason] Reason for changing the guild channel's topic
* @returns {Promise<GuildChannel>}
* @example
* // Set a new channel topic
* channel.setTopic('needs more rate limiting')
* .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`))
* .catch(console.error);
*/
setTopic(topic, reason) {
return this.edit({ topic }, reason);
}
/**
* Sets the RTC region of the channel.
* @name StageChannel#setRTCRegion
* @param {?string} rtcRegion The new region of the channel. Set to `null` to remove a specific region for the channel
* @param {string} [reason] The reason for modifying this region.
* @returns {Promise<StageChannel>}
* @example
* // Set the RTC region to sydney
* stageChannel.setRTCRegion('sydney');
* @example
* // Remove a fixed region for this channel - let Discord decide automatically
* stageChannel.setRTCRegion(null, 'We want to let Discord decide.');
*/
}
module.exports = StageChannel;