Skip to content

Commit 476a64f

Browse files
committed
Voice Channel Statuses
1 parent 6d610bc commit 476a64f

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

lib/Constants.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ export namespace Permissions {
470470
export const USE_EXTERNAL_SOUNDS = 35184372088832n; // 1 << 45
471471
export const SEND_VOICE_MESSAGES = 70368744177664n; // 1 << 46
472472
export const USE_CLYDE_AI = 140737488355328n;// 1 << 47
473+
export const SET_VOICE_CHANNEL_STATUS = 281474976710656n;// 1 << 48
473474
}
474475

475476
// bigints can't be used as object keys, so we need to convert them to strings
@@ -533,7 +534,8 @@ export const VoicePermissions = [
533534
Permissions.USE_SOUNDBOARD,
534535
Permissions.USE_EXTERNAL_SOUNDS,
535536
Permissions.SEND_VOICE_MESSAGES,
536-
Permissions.USE_CLYDE_AI
537+
Permissions.USE_CLYDE_AI,
538+
Permissions.SET_VOICE_CHANNEL_STATUS
537539
] as const;
538540
export const AllVoicePermissions = VoicePermissions.reduce((all, p) => all | p, 0n);
539541
export const AllVoicePermissionNames = VoicePermissions.map(p => PermissionValueToName[String(p) as `${typeof p}`]);
@@ -919,8 +921,10 @@ export enum AuditLogActionTypes {
919921

920922
HARMFUL_LINKS_BLOCKED_MESSAGE = 180,
921923

922-
HOME_SETTINGS_CREATE = 190,
923-
HOME_SETTINGS_UPDATE = 191,
924+
HOME_SETTINGS_CREATE = 190,
925+
HOME_SETTINGS_UPDATE = 191,
926+
VOICE_CHANNEL_STATUS_CREATE = 192,
927+
VOICE_CHANNEL_STATUS_DELETE = 193,
924928
}
925929

926930
export enum ApplicationCommandTypes {

lib/gateway/Shard.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,11 @@ export default class Shard extends TypedEmitter<ShardEvents> {
11521152
break;
11531153
}
11541154

1155+
case "VOICE_CHANNEL_STATUS_UPDATE": {
1156+
this.client.emit("voiceChannelStatusUpdate", this.client.getChannel<VoiceChannel>(packet.d.id) ?? { id: packet.d.id }, packet.d.status);
1157+
break;
1158+
}
1159+
11551160
case "VOICE_SERVER_UPDATE": {
11561161
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
11571162
this.client.voiceAdapters.get(packet.d.guild_id)?.onVoiceServerUpdate(packet.d);

lib/structures/VoiceChannel.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@ import type { JSONVoiceChannel } from "../types/json";
77

88
/** Represents a guild voice channel. */
99
export default class VoiceChannel extends TextableVoiceChannel<VoiceChannel> {
10+
/** The status of this voice channel. */
11+
status: string | null;
1012
declare type: ChannelTypes.GUILD_VOICE;
1113
constructor(data: RawVoiceChannel, client: Client) {
1214
super(data, client);
15+
this.status = null;
16+
this.update(data);
17+
}
18+
19+
protected override update(data: Partial<RawVoiceChannel>): void {
20+
this.status = data.status ?? null;
21+
super.update(data);
1322
}
1423

1524
override toJSON(): JSONVoiceChannel {
16-
return super.toJSON() as JSONVoiceChannel;
25+
return {
26+
...super.toJSON(),
27+
status: this.status,
28+
type: this.type
29+
};
1730
}
1831
}

lib/types/channels.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export interface RawChannel {
8484
rate_limit_per_user?: number;
8585
recipients?: Array<RawUser>;
8686
rtc_region?: string | null;
87+
status?: string | null;
8788
thread_metadata?: RawThreadMetadata;
8889
topic?: string | null;
8990
total_message_sent?: number;
@@ -98,7 +99,7 @@ export interface RawGroupChannel extends Required<Pick<RawChannel, "id" | "recip
9899
export interface RawTextChannel extends Omit<RawGuildChannel, "type">, Required<Pick<RawChannel, "default_auto_archive_duration" | "last_message_id" | "last_pin_timestamp" | "rate_limit_per_user" | "topic" | "nsfw" | "permission_overwrites" | "position">> { type: ChannelTypes.GUILD_TEXT; }
99100
export interface RawCategoryChannel extends Omit<RawGuildChannel, "type">, Required<Pick<RawChannel, "permission_overwrites" | "position">> { type: ChannelTypes.GUILD_CATEGORY; }
100101
export interface RawAnnouncementChannel extends Omit<RawTextChannel, "type"> { type: ChannelTypes.GUILD_ANNOUNCEMENT; }
101-
export interface RawVoiceChannel extends Omit<RawGuildChannel, "type">, Required<Pick<RawChannel, "bitrate" | "user_limit" | "video_quality_mode" | "rtc_region" | "nsfw" | "topic" | "permission_overwrites" | "position" | "last_message_id" | "rate_limit_per_user">> { type: ChannelTypes.GUILD_VOICE; }
102+
export interface RawVoiceChannel extends Omit<RawGuildChannel, "type">, Required<Pick<RawChannel, "bitrate" | "user_limit" | "video_quality_mode" | "rtc_region" | "nsfw" | "topic" | "permission_overwrites" | "position" | "last_message_id" | "rate_limit_per_user" | "status">> { type: ChannelTypes.GUILD_VOICE; }
102103
export interface RawStageChannel extends Omit<RawVoiceChannel, "type"> { type: ChannelTypes.GUILD_STAGE_VOICE; }
103104
export type RawThreadChannel = RawAnnouncementThreadChannel | RawPublicThreadChannel | RawPrivateThreadChannel;
104105
export interface RawAnnouncementThreadChannel extends Required<Pick<RawChannel, "id" | "guild_id" | "parent_id" | "owner_id" | "last_message_id" | "thread_metadata" | "message_count" | "member_count" | "rate_limit_per_user" | "flags" | "total_message_sent" | "newly_created" | "member">> { name: string; type: ChannelTypes.ANNOUNCEMENT_THREAD; }

lib/types/events.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ export interface ClientEvents {
220220
voiceChannelJoin: [member: Member, channel: VoiceChannel | StageChannel | Uncached];
221221
/** @event Emitted when a user leaves a voice channel. Requires the `GUILD_VOICE_STATES` intent. */
222222
voiceChannelLeave: [member: Member, channel: VoiceChannel | StageChannel | Uncached];
223+
/** @event Emitted when a voice channel's status is updated. Requires the `GUILD_VOICE_STATES` intent. */
224+
voiceChannelStatusUpdate: [channel: VoiceChannel | Uncached, status: string | null];
223225
/** @event Emitted when a user switches voice channels. Requires the `GUILD_VOICE_STATES` intent. */
224226
voiceChannelSwitch: [member: Member, channel: VoiceChannel | StageChannel | Uncached, oldChannel: VoiceChannel | StageChannel | Uncached | null];
225227
/** @event Emitted when a user's voice state is updated. Requires the `GUILD_VOICE_STATES` intent. */

lib/types/gateway-raw.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,11 @@ export interface VoiceChannelEffectSendPacket extends BaseDispatchPacket {
521521
t: "VOICE_CHANNEL_EFFECT_SEND";
522522
}
523523

524+
export interface VoiceChannelStatusUpdatePacket extends BaseDispatchPacket {
525+
d: { id: string; status: string | null; };
526+
t: "VOICE_CHANNEL_STATUS_UPDATE";
527+
}
528+
524529
export type AnyDispatchPacket = PresenceUpdatePacket | ReadyPacket | ResumedPacket |
525530
GuildCreatePacket | GuildDeletePacket | GuildUpdatePacket | ApplicationCommandPermissionsUpdatePacket | GuildAuditLogEntryCreatePacket |
526531
AutoModerationRuleCreatePacket | AutoModerationRuleDeletePacket | AutoModerationRuleUpdatePacket | AutoModerationActionExecutionPacket |
@@ -533,4 +538,4 @@ GuildScheduledEventCreatePacket | GuildScheduledEventDeletePacket | GuildSchedul
533538
IntegrationCreatePacket | IntegrationDeletePacket | IntegrationUpdatePacket |
534539
InviteCreatePacket | InviteDeletePacket |
535540
MessageCreatePacket | MessageDeletePacket | MessageDeleteBulkPacket | MessageUpdatePacket | MessageReactionAddPacket | MessageReactionRemovePacket | MessageReactionRemoveAllPacket | MessageReactionRemoveEmojiPacket |
536-
TypingStartPacket | UserUpdatePacket | VoiceStateUpdatePacket | VoiceChannelEffectSendPacket | VoiceServerUpdatePacket | WebhooksUpdatePacket | InteractionCreatePacket | StageInstanceCreatePacket | StageInstanceDeletePacket | StageInstanceUpdatePacket;
541+
TypingStartPacket | UserUpdatePacket | VoiceStateUpdatePacket | VoiceChannelEffectSendPacket | VoiceChannelStatusUpdatePacket | VoiceServerUpdatePacket | WebhooksUpdatePacket | InteractionCreatePacket | StageInstanceCreatePacket | StageInstanceDeletePacket | StageInstanceUpdatePacket;

lib/types/json.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ export interface JSONUser extends JSONBase {
621621
username: string;
622622
}
623623
export interface JSONVoiceChannel extends JSONTextableVoiceChannel {
624+
status: string | null;
624625
type: ChannelTypes.GUILD_VOICE;
625626
}
626627
export interface JSONVoiceState extends JSONBase {

0 commit comments

Comments
 (0)