Skip to content

Commit

Permalink
✨ feat: support text in voice channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Helloyunho committed Jan 9, 2023
1 parent 681fa28 commit c4064fd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/structures/guildVoiceChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import type {
VoiceChannelJoinOptions,
VoiceServerData
} from '../client/voice.ts'
import { Mixin } from "../../deps.ts";
import { TextChannel } from './textChannel.ts'

export class VoiceChannel extends GuildChannel {
export class VoiceChannel extends Mixin(GuildChannel, TextChannel) {
bitrate!: string
userLimit!: number
voiceStates = new GuildChannelVoiceStatesManager(
Expand Down
12 changes: 9 additions & 3 deletions src/types/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export interface GuildNewsChannelPayload
extends GuildTextBasedChannelPayload,
GuildThreadAvailableChannelPayload {}

export interface GuildVoiceChannelPayload extends GuildChannelPayload {
export interface GuildVoiceChannelPayload
extends GuildChannelPayload,
GuildTextBasedChannelPayload {
bitrate: string
user_limit: number
video_quality_mode: number
Expand Down Expand Up @@ -159,7 +161,9 @@ export interface ModifyGuildNewsChannelPayload
extends ModifyGuildTextBasedChannelPayload,
ModifyGuildThreadAvailableChannelPayload {}

export interface ModifyVoiceChannelPayload extends ModifyChannelPayload {
export interface ModifyVoiceChannelPayload
extends ModifyChannelPayload,
ModifyGuildTextBasedChannelPayload {
bitrate?: number | null
user_limit?: number | null
}
Expand Down Expand Up @@ -208,7 +212,9 @@ export interface ModifyGuildNewsChannelOption
extends ModifyGuildTextBasedChannelOption,
ModifyGuildThreadAvailableChannelOption {}

export interface ModifyVoiceChannelOption extends ModifyChannelOption {
export interface ModifyVoiceChannelOption
extends ModifyChannelOption,
ModifyGuildTextBasedChannelOption {
bitrate?: number | null
userLimit?: number | null
}
Expand Down
4 changes: 2 additions & 2 deletions src/types/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ export type GuildThreadAvailableChannelPayloads =
export type GuildTextBasedPayloads =
| GuildTextBasedChannelPayload
| GuildTextChannelPayload
| GuildVoiceChannelPayload
| GuildNewsChannelPayload

export type GuildChannelPayloads =
| GuildTextBasedPayloads
| GuildThreadAvailableChannelPayloads
| GuildVoiceChannelPayload
| GuildCategoryChannelPayload

export type GuildThreadAvailableChannels =
Expand All @@ -218,11 +218,11 @@ export type GuildTextBasedChannels =
| GuildThreadAvailableChannels
| GuildTextChannel
| NewsChannel
| VoiceChannel

export type GuildChannels =
| GuildChannel
| GuildTextBasedChannels
| VoiceChannel
| CategoryChannel

export interface GuildCreatePayload {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type EveryTextChannelTypes =
| DMChannel
| GroupDMChannel
| ThreadChannel
| VoiceChannel

export type EveryGuildThreadAvailableChannelTypes =
| GuildTextChannel
Expand All @@ -58,20 +59,19 @@ export type EveryTextChannelPayloadTypes =
| DMChannelPayload
| GroupDMChannelPayload
| ThreadChannelPayload
| GuildVoiceChannelPayload

export type EveryChannelTypes =
| Channel
| GuildChannel
| CategoryChannel
| VoiceChannel
| StageVoiceChannel
| EveryTextChannelTypes
| EveryGuildThreadAvailableChannelTypes

export type EveryChannelPayloadTypes =
| ChannelPayload
| GuildCategoryChannelPayload
| GuildVoiceChannelPayload
| GuildStageChannelPayload
| EveryTextChannelPayloadTypes
| EveryGuildThreadAvailableChannelPayloadTypes
Expand Down
6 changes: 4 additions & 2 deletions src/utils/channelTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export function isGuildBasedTextChannel(
channel.type === ChannelTypes.GUILD_NEWS ||
channel.type === ChannelTypes.NEWS_THREAD ||
channel.type === ChannelTypes.PRIVATE_THREAD ||
channel.type === ChannelTypes.PUBLIC_THREAD
channel.type === ChannelTypes.PUBLIC_THREAD ||
channel.type === ChannelTypes.GUILD_VOICE
)
}

Expand Down Expand Up @@ -96,7 +97,8 @@ export function isTextChannel(channel: Channel): channel is TextChannel {
channel.type === ChannelTypes.GUILD_NEWS ||
channel.type === ChannelTypes.NEWS_THREAD ||
channel.type === ChannelTypes.PRIVATE_THREAD ||
channel.type === ChannelTypes.PUBLIC_THREAD
channel.type === ChannelTypes.PUBLIC_THREAD ||
channel.type === ChannelTypes.GUILD_VOICE
)
}

Expand Down

0 comments on commit c4064fd

Please sign in to comment.