feat (VoiceState) add setStatus function
This commit is contained in:
parent
b65545ad81
commit
5390ad3851
@ -75,6 +75,7 @@ const Messages = {
|
|||||||
CLIENT_NO_CALL: 'No call exists!',
|
CLIENT_NO_CALL: 'No call exists!',
|
||||||
|
|
||||||
VOICE_NOT_STAGE_CHANNEL: 'You are only allowed to do this in stage channels.',
|
VOICE_NOT_STAGE_CHANNEL: 'You are only allowed to do this in stage channels.',
|
||||||
|
VOICE_NOT_IN_GUILD: 'You are only allowed to do this in guild channels.',
|
||||||
|
|
||||||
VOICE_STATE_NOT_OWN:
|
VOICE_STATE_NOT_OWN:
|
||||||
'You cannot self-deafen/mute/request to speak on VoiceStates that do not belong to the ClientUser.',
|
'You cannot self-deafen/mute/request to speak on VoiceStates that do not belong to the ClientUser.',
|
||||||
|
@ -217,16 +217,25 @@ class VoiceState extends Base {
|
|||||||
/**
|
/**
|
||||||
* Sets the status of the voice channel
|
* Sets the status of the voice channel
|
||||||
* @param {string} status The message to set the channel status to
|
* @param {string} status The message to set the channel status to
|
||||||
|
* @example
|
||||||
|
* // Setting the status to something
|
||||||
|
* guild.members.me.voice.setStatus("something")
|
||||||
|
* @example
|
||||||
|
* // Removing the status
|
||||||
|
* guild.members.me.voice.setStatus("")
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async setStatus(status) {
|
async setStatus(status) {
|
||||||
|
// PUT https://discord.com/api/v9/channels/channelID/voice-status
|
||||||
if (this.channel?.id) {
|
if (this.channel?.id) {
|
||||||
if (this.channel?.type !== 'GUILD_VOICE') throw new Error('VOICE_NOT_GUILD_CHANNEL');
|
// You can set the staus in normal voice channels and in stages so any type starting with GUILD should work
|
||||||
|
if (!this.channel?.type.startsWith('GUILD')) throw new Error('VOICE_NOT_IN_GUILD');
|
||||||
|
|
||||||
await this.client.api.channels(this.channel.id, 'voice-status').put({
|
await this.client.api.channels(this.channel.id, 'voice-status').put({
|
||||||
data: {
|
data: {
|
||||||
status,
|
status,
|
||||||
},
|
},
|
||||||
|
versioned: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user