Skip to content

Commit

Permalink
modified perms for threads to ensure commands run in threads despite …
Browse files Browse the repository at this point in the history
…the bot missing send message perms in the parent channel (#1826)

Co-authored-by: Ashish <[email protected]>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Jan 21, 2025
1 parent 50b3d40 commit 24dba81
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions customcommands/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,16 @@ func handleMessageReactions(evt *eventsystem.EventData) {
if cState == nil {
return
}
// if the execution channel is a thread, check for send message in thread perms on the parent channel.
permToCheck := discordgo.PermissionSendMessages
cID := cState.ID
if cState.Type.IsThread() {
permToCheck = discordgo.PermissionSendMessagesInThreads
cID = cState.ParentID
}

if hasPerms, _ := bot.BotHasPermissionGS(evt.GS, cState.ID, discordgo.PermissionSendMessages); !hasPerms {
// don't run in channel we don't have perms in
if hasPerms, _ := bot.BotHasPermissionGS(evt.GS, cID, permToCheck); !hasPerms {
// don't run in channel or thread we don't have perms in
return
}

Expand Down

0 comments on commit 24dba81

Please sign in to comment.