-
Notifications
You must be signed in to change notification settings - Fork 4
fix: VC自動作成時の権限問題を修正 #28
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
Changes from all commits
8559eb9
7b313b6
02a117e
5edd13c
2ddb8a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: [ | ||
|
|
@@ -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
|
||
| console.error("vc-join: チャンネル作成に失敗しました:", error); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newState.membercan benullonVoiceState(e.g., partials). In that case this code will pass an empty string as the overwriteid, which will cause the channel create call to fail (and also produce a channel name withundefined). Add an early guard (e.g., return if!newState.member) and usenewState.member.iddirectly instead of falling back to"".