From 1c0aefd7ec21849e3238e5e6df52adf890cf429a Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Mon, 24 Oct 2022 23:29:09 +0700 Subject: [PATCH] typing: add CallOptions --- src/structures/DMChannel.js | 11 ++++------- src/structures/PartialGroupDMChannel.js | 10 ++++------ typings/index.d.ts | 10 ++++++++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/structures/DMChannel.js b/src/structures/DMChannel.js index ff85bcc..2a66eaa 100644 --- a/src/structures/DMChannel.js +++ b/src/structures/DMChannel.js @@ -124,16 +124,13 @@ class DMChannel extends Channel { ), ); } else { - this.client.api - .channels(this.id) - .call.ring.post({ - data: { + if (options?.ring) { + this.client.api.channels(this.id).call.ring.post({ + body: { recipients: null, }, - }) - .catch(e => { - console.error('Emit ring error:', e.message); }); + } const connection = joinVoiceChannel({ channelId: this.id, guildId: null, diff --git a/src/structures/PartialGroupDMChannel.js b/src/structures/PartialGroupDMChannel.js index b551dc7..90117fb 100644 --- a/src/structures/PartialGroupDMChannel.js +++ b/src/structures/PartialGroupDMChannel.js @@ -301,6 +301,7 @@ class PartialGroupDMChannel extends Channel { * @typedef {Object} CallOptions * @property {boolean} [selfDeaf] Whether to deafen yourself * @property {boolean} [selfMute] Whether to mute yourself + * @property {boolean} [ring=true] Emit a ringtone */ // Testing feature: Call // URL: https://discord.com/api/v9/channels/DMchannelId/call/ring @@ -319,16 +320,13 @@ class PartialGroupDMChannel extends Channel { ), ); } else { - this.client.api - .channels(this.id) - .call.ring.post({ + if (options?.ring) { + this.client.api.channels(this.id).call.ring.post({ body: { recipients: null, }, - }) - .catch(e => { - console.error('Emit ring error:', e.message); }); + } const connection = joinVoiceChannel({ channelId: this.id, guildId: null, diff --git a/typings/index.d.ts b/typings/index.d.ts index 71d06c2..6d35267 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1198,13 +1198,19 @@ export class DMChannel extends TextBasedChannelMixin(Channel, [ public flags: Readonly; public fetch(force?: boolean): Promise; public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator; - public call(options?: object): Promise; + public call(options?: CallOptions): Promise; public sync(): undefined; public readonly shard: WebSocketShard; public readonly voiceUsers: Collection; public readonly voiceConnection?: VoiceConnection; } +export interface CallOptions { + selfDeaf?: boolean; + selfMute?: boolean; + ring?: boolean; +} + export class Emoji extends Base { protected constructor(client: Client, emoji: RawEmojiData); public animated: boolean | null; @@ -2380,7 +2386,7 @@ export class PartialGroupDMChannel extends TextBasedChannelMixin(Channel, [ public delete(slient?: boolean): Promise; public setOwner(user: UserResolvable): Promise; public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator; - public call(options?: object): Promise; + public call(options?: CallOptions): Promise; public sync(): undefined; public readonly shard: WebSocketShard; public readonly voiceUsers: Collection;