Skip to content

Commit b525ee2

Browse files
authored
Merge pull request #338 from Helloyunho/main
✨ feat: support text in voice channel (Closes #260)
2 parents 681fa28 + a974215 commit b525ee2

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

src/structures/guildVoiceChannel.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import type {
1414
VoiceChannelJoinOptions,
1515
VoiceServerData
1616
} from '../client/voice.ts'
17+
import { Mixin } from '../../deps.ts'
18+
import { TextChannel } from './textChannel.ts'
1719

18-
export class VoiceChannel extends GuildChannel {
20+
export class VoiceChannel extends Mixin(GuildChannel, TextChannel) {
1921
bitrate!: string
2022
userLimit!: number
2123
voiceStates = new GuildChannelVoiceStatesManager(

src/types/channel.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export interface GuildNewsChannelPayload
7272
extends GuildTextBasedChannelPayload,
7373
GuildThreadAvailableChannelPayload {}
7474

75-
export interface GuildVoiceChannelPayload extends GuildChannelPayload {
75+
export interface GuildVoiceChannelPayload
76+
extends GuildChannelPayload,
77+
GuildTextBasedChannelPayload {
7678
bitrate: string
7779
user_limit: number
7880
video_quality_mode: number
@@ -159,7 +161,9 @@ export interface ModifyGuildNewsChannelPayload
159161
extends ModifyGuildTextBasedChannelPayload,
160162
ModifyGuildThreadAvailableChannelPayload {}
161163

162-
export interface ModifyVoiceChannelPayload extends ModifyChannelPayload {
164+
export interface ModifyVoiceChannelPayload
165+
extends ModifyChannelPayload,
166+
ModifyGuildTextBasedChannelPayload {
163167
bitrate?: number | null
164168
user_limit?: number | null
165169
}
@@ -208,7 +212,9 @@ export interface ModifyGuildNewsChannelOption
208212
extends ModifyGuildTextBasedChannelOption,
209213
ModifyGuildThreadAvailableChannelOption {}
210214

211-
export interface ModifyVoiceChannelOption extends ModifyChannelOption {
215+
export interface ModifyVoiceChannelOption
216+
extends ModifyChannelOption,
217+
ModifyGuildTextBasedChannelOption {
212218
bitrate?: number | null
213219
userLimit?: number | null
214220
}

src/types/guild.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ export type GuildThreadAvailableChannelPayloads =
200200
export type GuildTextBasedPayloads =
201201
| GuildTextBasedChannelPayload
202202
| GuildTextChannelPayload
203+
| GuildVoiceChannelPayload
203204
| GuildNewsChannelPayload
204205

205206
export type GuildChannelPayloads =
206207
| GuildTextBasedPayloads
207208
| GuildThreadAvailableChannelPayloads
208-
| GuildVoiceChannelPayload
209209
| GuildCategoryChannelPayload
210210

211211
export type GuildThreadAvailableChannels =
@@ -218,11 +218,11 @@ export type GuildTextBasedChannels =
218218
| GuildThreadAvailableChannels
219219
| GuildTextChannel
220220
| NewsChannel
221+
| VoiceChannel
221222

222223
export type GuildChannels =
223224
| GuildChannel
224225
| GuildTextBasedChannels
225-
| VoiceChannel
226226
| CategoryChannel
227227

228228
export interface GuildCreatePayload {

src/utils/channel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type EveryTextChannelTypes =
3939
| DMChannel
4040
| GroupDMChannel
4141
| ThreadChannel
42+
| VoiceChannel
4243

4344
export type EveryGuildThreadAvailableChannelTypes =
4445
| GuildTextChannel
@@ -58,20 +59,19 @@ export type EveryTextChannelPayloadTypes =
5859
| DMChannelPayload
5960
| GroupDMChannelPayload
6061
| ThreadChannelPayload
62+
| GuildVoiceChannelPayload
6163

6264
export type EveryChannelTypes =
6365
| Channel
6466
| GuildChannel
6567
| CategoryChannel
66-
| VoiceChannel
6768
| StageVoiceChannel
6869
| EveryTextChannelTypes
6970
| EveryGuildThreadAvailableChannelTypes
7071

7172
export type EveryChannelPayloadTypes =
7273
| ChannelPayload
7374
| GuildCategoryChannelPayload
74-
| GuildVoiceChannelPayload
7575
| GuildStageChannelPayload
7676
| EveryTextChannelPayloadTypes
7777
| EveryGuildThreadAvailableChannelPayloadTypes

src/utils/channelTypes.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export function isGuildBasedTextChannel(
3737
channel.type === ChannelTypes.GUILD_NEWS ||
3838
channel.type === ChannelTypes.NEWS_THREAD ||
3939
channel.type === ChannelTypes.PRIVATE_THREAD ||
40-
channel.type === ChannelTypes.PUBLIC_THREAD
40+
channel.type === ChannelTypes.PUBLIC_THREAD ||
41+
channel.type === ChannelTypes.GUILD_VOICE
4142
)
4243
}
4344

@@ -96,7 +97,8 @@ export function isTextChannel(channel: Channel): channel is TextChannel {
9697
channel.type === ChannelTypes.GUILD_NEWS ||
9798
channel.type === ChannelTypes.NEWS_THREAD ||
9899
channel.type === ChannelTypes.PRIVATE_THREAD ||
99-
channel.type === ChannelTypes.PUBLIC_THREAD
100+
channel.type === ChannelTypes.PUBLIC_THREAD ||
101+
channel.type === ChannelTypes.GUILD_VOICE
100102
)
101103
}
102104

0 commit comments

Comments
 (0)