Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/handlers/events/vc/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ const handleVcJoin = (async (oldState: VoiceState, newState: VoiceState) => {
type: ChannelType.GuildVoice,
parent: newState.channel.parentId ?? undefined,
permissionOverwrites: [
{
id: botConfig.role.memberId,
allow: [
PermissionFlagsBits.ViewChannel,
PermissionFlagsBits.Connect
],
},
{
id: newState.member?.id || newState.member?.user.id || "",
allow: [
Comment on lines +22 to 25
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newState.member can be null on VoiceState (e.g., partials). In that case this code will pass an empty string as the overwrite id, which will cause the channel create call to fail (and also produce a channel name with undefined). Add an early guard (e.g., return if !newState.member) and use newState.member.id directly instead of falling back to "".

Copilot uses AI. Check for mistakes.
Expand All @@ -22,18 +29,13 @@ const handleVcJoin = (async (oldState: VoiceState, newState: VoiceState) => {
PermissionFlagsBits.ManageChannels,
],
},
{
id: newState.guild.roles.everyone.id,
deny: [PermissionFlagsBits.ViewChannel],
},
{
id: botConfig.role.memberId,
allow: [PermissionFlagsBits.ViewChannel, PermissionFlagsBits.Connect],
}
],
});

await newState.member?.voice.setChannel(channel);
await channel.permissionOverwrites.create(newState.guild.roles.everyone, {
ViewChannel: false,
});
} catch (error) {
Comment on lines 34 to 39
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @everyone deny is applied after the channel is created and after moving the member into it. That leaves a window where the new channel may be visible/joinable based on guild default permissions, which undermines the privacy goal. Prefer including the @everyone deny overwrite directly in the initial permissionOverwrites passed to channels.create (and then you can drop the extra API call).

Copilot uses AI. Check for mistakes.
console.error("vc-join: チャンネル作成に失敗しました:", error);
}
Expand Down