Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(APIVoiceChannel): support text in voice, properties last_message_id and rate_limit_per_user #544

Merged
merged 6 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 24 additions & 18 deletions deno/payloads/v10/channel.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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