feat(VoiceState): setSuppress, requestSpeak (#212)

* feat: setSuppress, requestSpeak

* fix: assing

* fix: never

* fix: set request timestamp
This commit is contained in:
Marcos Susaña 2024-06-24 15:21:11 -04:00 committed by GitHub
parent 6547f71b1f
commit ef5370462b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,7 +22,7 @@ export class VoiceState extends Base {
}
async member(force?: boolean) {
return (this.withMember ??= await this.client.members.fetch(this.guildId, this.userId, force));
return (this.withMember = await this.client.members.fetch(this.guildId, this.userId, force));
}
async user(force?: boolean) {
@ -48,6 +48,24 @@ export class VoiceState extends Base {
});
}
async setSuppress(suppress = !this.suppress) {
await this.client.proxy.guilds(this.guildId)['voice-states']['@me'].patch({
body: { suppress },
});
this.suppress = suppress;
}
async requestSpeak(date: string | Date = new Date()) {
if (typeof date === 'string') date = new Date(date);
if (Number.isNaN(date)) return Promise.reject('Invalid date');
date = date.toISOString();
await this.client.proxy.guilds(this.guildId)['voice-states']['@me'].patch({
body: { request_to_speak_timestamp: date },
});
this.requestToSpeakTimestamp = date;
}
async disconnect(reason?: string) {
return this.setChannel(null, reason);
}