typing: add CallOptions

This commit is contained in:
March 7th 2022-10-24 23:29:09 +07:00
parent 95ef7a2b41
commit 1c0aefd7ec
3 changed files with 16 additions and 15 deletions

View File

@ -124,16 +124,13 @@ class DMChannel extends Channel {
), ),
); );
} else { } else {
this.client.api if (options?.ring) {
.channels(this.id) this.client.api.channels(this.id).call.ring.post({
.call.ring.post({ body: {
data: {
recipients: null, recipients: null,
}, },
})
.catch(e => {
console.error('Emit ring error:', e.message);
}); });
}
const connection = joinVoiceChannel({ const connection = joinVoiceChannel({
channelId: this.id, channelId: this.id,
guildId: null, guildId: null,

View File

@ -301,6 +301,7 @@ class PartialGroupDMChannel extends Channel {
* @typedef {Object} CallOptions * @typedef {Object} CallOptions
* @property {boolean} [selfDeaf] Whether to deafen yourself * @property {boolean} [selfDeaf] Whether to deafen yourself
* @property {boolean} [selfMute] Whether to mute yourself * @property {boolean} [selfMute] Whether to mute yourself
* @property {boolean} [ring=true] Emit a ringtone
*/ */
// Testing feature: Call // Testing feature: Call
// URL: https://discord.com/api/v9/channels/DMchannelId/call/ring // URL: https://discord.com/api/v9/channels/DMchannelId/call/ring
@ -319,16 +320,13 @@ class PartialGroupDMChannel extends Channel {
), ),
); );
} else { } else {
this.client.api if (options?.ring) {
.channels(this.id) this.client.api.channels(this.id).call.ring.post({
.call.ring.post({
body: { body: {
recipients: null, recipients: null,
}, },
})
.catch(e => {
console.error('Emit ring error:', e.message);
}); });
}
const connection = joinVoiceChannel({ const connection = joinVoiceChannel({
channelId: this.id, channelId: this.id,
guildId: null, guildId: null,

10
typings/index.d.ts vendored
View File

@ -1198,13 +1198,19 @@ export class DMChannel extends TextBasedChannelMixin(Channel, [
public flags: Readonly<ChannelFlags>; public flags: Readonly<ChannelFlags>;
public fetch(force?: boolean): Promise<this>; public fetch(force?: boolean): Promise<this>;
public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator; public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator;
public call(options?: object): Promise<VoiceConnection>; public call(options?: CallOptions): Promise<VoiceConnection>;
public sync(): undefined; public sync(): undefined;
public readonly shard: WebSocketShard; public readonly shard: WebSocketShard;
public readonly voiceUsers: Collection<Snowflake, User>; public readonly voiceUsers: Collection<Snowflake, User>;
public readonly voiceConnection?: VoiceConnection; public readonly voiceConnection?: VoiceConnection;
} }
export interface CallOptions {
selfDeaf?: boolean;
selfMute?: boolean;
ring?: boolean;
}
export class Emoji extends Base { export class Emoji extends Base {
protected constructor(client: Client, emoji: RawEmojiData); protected constructor(client: Client, emoji: RawEmojiData);
public animated: boolean | null; public animated: boolean | null;
@ -2380,7 +2386,7 @@ export class PartialGroupDMChannel extends TextBasedChannelMixin(Channel, [
public delete(slient?: boolean): Promise<this>; public delete(slient?: boolean): Promise<this>;
public setOwner(user: UserResolvable): Promise<PartialGroupDMChannel>; public setOwner(user: UserResolvable): Promise<PartialGroupDMChannel>;
public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator; public readonly voiceAdapterCreator: InternalDiscordGatewayAdapterCreator;
public call(options?: object): Promise<VoiceConnection>; public call(options?: CallOptions): Promise<VoiceConnection>;
public sync(): undefined; public sync(): undefined;
public readonly shard: WebSocketShard; public readonly shard: WebSocketShard;
public readonly voiceUsers: Collection<Snowflake, User>; public readonly voiceUsers: Collection<Snowflake, User>;