Skip to content

Commit

Permalink
feat(APIVoiceChannel): support text in voice, properties `last_messag…
Browse files Browse the repository at this point in the history
…e_id` and `rate_limit_per_user` (#544)
  • Loading branch information
Mateo-tem committed Aug 9, 2022
1 parent 9a50367 commit 4488d8f
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 72 deletions.
42 changes: 24 additions & 18 deletions deno/payloads/v10/channel.ts
Expand Up @@ -39,7 +39,6 @@ export interface APIChannelBase<T extends ChannelType> extends APIPartialChannel
flags?: ChannelFlags;
}

// TODO: update when text in voice is released
export type TextChannelType =
| ChannelType.DM
| ChannelType.GroupDM
Expand All @@ -48,7 +47,8 @@ export type TextChannelType =
| ChannelType.GuildPrivateThread
| ChannelType.GuildNewsThread
| ChannelType.GuildText
| ChannelType.GuildForum;
| ChannelType.GuildForum
| ChannelType.GuildVoice;

export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildNews,
Expand All @@ -60,6 +60,16 @@ export interface APITextBasedChannel<T extends ChannelType> extends APIChannelBa
* The id of the last message sent in this channel (may not point to an existing or valid message)
*/
last_message_id?: Snowflake | null;
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
*
* `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
*
* For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
* The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
*/
rate_limit_per_user?: number;
}

export interface APIGuildChannel<T extends ChannelType> extends APIChannelBase<T> {
Expand Down Expand Up @@ -111,23 +121,11 @@ export interface APIGuildTextChannel<T extends GuildTextChannelType>
last_pin_timestamp?: string | null;
}

export interface APITextChannel extends APIGuildTextChannel<ChannelType.GuildText> {
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
*
* `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
*
* For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
* The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
*/
rate_limit_per_user?: number;
}

export type APITextChannel = APIGuildTextChannel<ChannelType.GuildText>;
export type APINewsChannel = APIGuildTextChannel<ChannelType.GuildNews>;
export type APIGuildCategoryChannel = APIGuildChannel<ChannelType.GuildCategory>;

export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageVoice | ChannelType.GuildVoice> {
export interface APIVoiceChannelBase<T extends ChannelType> extends APIGuildChannel<T> {
/**
* The bitrate (in bits) of the voice channel
*/
Expand All @@ -142,6 +140,11 @@ export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageV
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
rtc_region?: string | null;
}

export interface APIGuildVoiceChannel
extends APIVoiceChannelBase<ChannelType.GuildVoice>,
APITextBasedChannel<ChannelType.GuildVoice> {
/**
* The camera video quality mode of the voice channel, `1` when not present
*
Expand All @@ -150,7 +153,9 @@ export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageV
video_quality_mode?: VideoQualityMode;
}

interface APIDMChannelBase<T extends ChannelType> extends APITextBasedChannel<T> {
export type APIGuildStageVoiceChannel = APIVoiceChannelBase<ChannelType.GuildStageVoice>;

export interface APIDMChannelBase<T extends ChannelType> extends Omit<APITextBasedChannel<T>, 'rate_limit_per_user'> {
/**
* The recipients of the DM
*
Expand Down Expand Up @@ -242,7 +247,8 @@ export type APIChannel =
| APIDMChannel
| APITextChannel
| APINewsChannel
| APIVoiceChannel
| APIGuildVoiceChannel
| APIGuildStageVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APINewsChannel
Expand Down
42 changes: 24 additions & 18 deletions deno/payloads/v9/channel.ts
Expand Up @@ -39,7 +39,6 @@ export interface APIChannelBase<T extends ChannelType> extends APIPartialChannel
flags?: ChannelFlags;
}

// TODO: update when text in voice is released
export type TextChannelType =
| ChannelType.DM
| ChannelType.GroupDM
Expand All @@ -48,7 +47,8 @@ export type TextChannelType =
| ChannelType.GuildPrivateThread
| ChannelType.GuildNewsThread
| ChannelType.GuildText
| ChannelType.GuildForum;
| ChannelType.GuildForum
| ChannelType.GuildVoice;

export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildNews,
Expand All @@ -60,6 +60,16 @@ export interface APITextBasedChannel<T extends ChannelType> extends APIChannelBa
* The id of the last message sent in this channel (may not point to an existing or valid message)
*/
last_message_id?: Snowflake | null;
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
*
* `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
*
* For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
* The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
*/
rate_limit_per_user?: number;
}

export interface APIGuildChannel<T extends ChannelType> extends APIChannelBase<T> {
Expand Down Expand Up @@ -111,23 +121,11 @@ export interface APIGuildTextChannel<T extends GuildTextChannelType>
last_pin_timestamp?: string | null;
}

export interface APITextChannel extends APIGuildTextChannel<ChannelType.GuildText> {
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
*
* `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
*
* For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
* The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
*/
rate_limit_per_user?: number;
}

export type APITextChannel = APIGuildTextChannel<ChannelType.GuildText>;
export type APINewsChannel = APIGuildTextChannel<ChannelType.GuildNews>;
export type APIGuildCategoryChannel = APIGuildChannel<ChannelType.GuildCategory>;

export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageVoice | ChannelType.GuildVoice> {
export interface APIVoiceChannelBase<T extends ChannelType> extends APIGuildChannel<T> {
/**
* The bitrate (in bits) of the voice channel
*/
Expand All @@ -142,6 +140,11 @@ export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageV
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
rtc_region?: string | null;
}

export interface APIGuildVoiceChannel
extends APIVoiceChannelBase<ChannelType.GuildVoice>,
APITextBasedChannel<ChannelType.GuildVoice> {
/**
* The camera video quality mode of the voice channel, `1` when not present
*
Expand All @@ -150,7 +153,9 @@ export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageV
video_quality_mode?: VideoQualityMode;
}

interface APIDMChannelBase<T extends ChannelType> extends APITextBasedChannel<T> {
export type APIGuildStageVoiceChannel = APIVoiceChannelBase<ChannelType.GuildStageVoice>;

export interface APIDMChannelBase<T extends ChannelType> extends Omit<APITextBasedChannel<T>, 'rate_limit_per_user'> {
/**
* The recipients of the DM
*
Expand Down Expand Up @@ -242,7 +247,8 @@ export type APIChannel =
| APIDMChannel
| APITextChannel
| APINewsChannel
| APIVoiceChannel
| APIGuildVoiceChannel
| APIGuildStageVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APINewsChannel
Expand Down
42 changes: 24 additions & 18 deletions payloads/v10/channel.ts
Expand Up @@ -39,7 +39,6 @@ export interface APIChannelBase<T extends ChannelType> extends APIPartialChannel
flags?: ChannelFlags;
}

// TODO: update when text in voice is released
export type TextChannelType =
| ChannelType.DM
| ChannelType.GroupDM
Expand All @@ -48,7 +47,8 @@ export type TextChannelType =
| ChannelType.GuildPrivateThread
| ChannelType.GuildNewsThread
| ChannelType.GuildText
| ChannelType.GuildForum;
| ChannelType.GuildForum
| ChannelType.GuildVoice;

export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildNews,
Expand All @@ -60,6 +60,16 @@ export interface APITextBasedChannel<T extends ChannelType> extends APIChannelBa
* The id of the last message sent in this channel (may not point to an existing or valid message)
*/
last_message_id?: Snowflake | null;
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
*
* `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
*
* For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
* The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
*/
rate_limit_per_user?: number;
}

export interface APIGuildChannel<T extends ChannelType> extends APIChannelBase<T> {
Expand Down Expand Up @@ -111,23 +121,11 @@ export interface APIGuildTextChannel<T extends GuildTextChannelType>
last_pin_timestamp?: string | null;
}

export interface APITextChannel extends APIGuildTextChannel<ChannelType.GuildText> {
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
*
* `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
*
* For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
* The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
*/
rate_limit_per_user?: number;
}

export type APITextChannel = APIGuildTextChannel<ChannelType.GuildText>;
export type APINewsChannel = APIGuildTextChannel<ChannelType.GuildNews>;
export type APIGuildCategoryChannel = APIGuildChannel<ChannelType.GuildCategory>;

export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageVoice | ChannelType.GuildVoice> {
export interface APIVoiceChannelBase<T extends ChannelType> extends APIGuildChannel<T> {
/**
* The bitrate (in bits) of the voice channel
*/
Expand All @@ -142,6 +140,11 @@ export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageV
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
rtc_region?: string | null;
}

export interface APIGuildVoiceChannel
extends APIVoiceChannelBase<ChannelType.GuildVoice>,
APITextBasedChannel<ChannelType.GuildVoice> {
/**
* The camera video quality mode of the voice channel, `1` when not present
*
Expand All @@ -150,7 +153,9 @@ export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageV
video_quality_mode?: VideoQualityMode;
}

interface APIDMChannelBase<T extends ChannelType> extends APITextBasedChannel<T> {
export type APIGuildStageVoiceChannel = APIVoiceChannelBase<ChannelType.GuildStageVoice>;

export interface APIDMChannelBase<T extends ChannelType> extends Omit<APITextBasedChannel<T>, 'rate_limit_per_user'> {
/**
* The recipients of the DM
*
Expand Down Expand Up @@ -242,7 +247,8 @@ export type APIChannel =
| APIDMChannel
| APITextChannel
| APINewsChannel
| APIVoiceChannel
| APIGuildVoiceChannel
| APIGuildStageVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APINewsChannel
Expand Down
42 changes: 24 additions & 18 deletions payloads/v9/channel.ts
Expand Up @@ -39,7 +39,6 @@ export interface APIChannelBase<T extends ChannelType> extends APIPartialChannel
flags?: ChannelFlags;
}

// TODO: update when text in voice is released
export type TextChannelType =
| ChannelType.DM
| ChannelType.GroupDM
Expand All @@ -48,7 +47,8 @@ export type TextChannelType =
| ChannelType.GuildPrivateThread
| ChannelType.GuildNewsThread
| ChannelType.GuildText
| ChannelType.GuildForum;
| ChannelType.GuildForum
| ChannelType.GuildVoice;

export type GuildChannelType = Exclude<
TextChannelType | ChannelType.GuildVoice | ChannelType.GuildStageVoice | ChannelType.GuildNews,
Expand All @@ -60,6 +60,16 @@ export interface APITextBasedChannel<T extends ChannelType> extends APIChannelBa
* The id of the last message sent in this channel (may not point to an existing or valid message)
*/
last_message_id?: Snowflake | null;
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
*
* `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
*
* For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
* The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
*/
rate_limit_per_user?: number;
}

export interface APIGuildChannel<T extends ChannelType> extends APIChannelBase<T> {
Expand Down Expand Up @@ -111,23 +121,11 @@ export interface APIGuildTextChannel<T extends GuildTextChannelType>
last_pin_timestamp?: string | null;
}

export interface APITextChannel extends APIGuildTextChannel<ChannelType.GuildText> {
/**
* Amount of seconds a user has to wait before sending another message (0-21600);
* bots, as well as users with the permission `MANAGE_MESSAGES` or `MANAGE_CHANNELS`, are unaffected
*
* `rate_limit_per_user` also applies to thread creation. Users can send one message and create one thread during each `rate_limit_per_user` interval.
*
* For thread channels, `rate_limit_per_user` is only returned if the field is set to a non-zero and non-null value.
* The absence of this field in API calls and Gateway events should indicate that slowmode has been reset to the default value.
*/
rate_limit_per_user?: number;
}

export type APITextChannel = APIGuildTextChannel<ChannelType.GuildText>;
export type APINewsChannel = APIGuildTextChannel<ChannelType.GuildNews>;
export type APIGuildCategoryChannel = APIGuildChannel<ChannelType.GuildCategory>;

export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageVoice | ChannelType.GuildVoice> {
export interface APIVoiceChannelBase<T extends ChannelType> extends APIGuildChannel<T> {
/**
* The bitrate (in bits) of the voice channel
*/
Expand All @@ -142,6 +140,11 @@ export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageV
* See https://discord.com/developers/docs/resources/voice#voice-region-object
*/
rtc_region?: string | null;
}

export interface APIGuildVoiceChannel
extends APIVoiceChannelBase<ChannelType.GuildVoice>,
APITextBasedChannel<ChannelType.GuildVoice> {
/**
* The camera video quality mode of the voice channel, `1` when not present
*
Expand All @@ -150,7 +153,9 @@ export interface APIVoiceChannel extends APIGuildChannel<ChannelType.GuildStageV
video_quality_mode?: VideoQualityMode;
}

interface APIDMChannelBase<T extends ChannelType> extends APITextBasedChannel<T> {
export type APIGuildStageVoiceChannel = APIVoiceChannelBase<ChannelType.GuildStageVoice>;

export interface APIDMChannelBase<T extends ChannelType> extends Omit<APITextBasedChannel<T>, 'rate_limit_per_user'> {
/**
* The recipients of the DM
*
Expand Down Expand Up @@ -242,7 +247,8 @@ export type APIChannel =
| APIDMChannel
| APITextChannel
| APINewsChannel
| APIVoiceChannel
| APIGuildVoiceChannel
| APIGuildStageVoiceChannel
| APIGuildCategoryChannel
| APIThreadChannel
| APINewsChannel
Expand Down

0 comments on commit 4488d8f

Please sign in to comment.