Skip to content

Commit

Permalink
Check applicable permissions while deleting a message. (Thanks @pronoob
Browse files Browse the repository at this point in the history
… for reporting)
  • Loading branch information
ayn2op committed Mar 26, 2024
1 parent 23a9eab commit 20fd9e3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/messages_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ func (mt *MessagesText) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
}

m := ms[mt.selectedMessage]
clientID := discordState.Ready().User.ID

ps, err := discordState.Permissions(mainFlex.guildsTree.selectedChannelID, discordState.Ready().User.ID)
if err != nil {
return nil
}

if m.Author.ID != clientID && !ps.Has(discord.PermissionManageMessages) {
return nil
}

if err := discordState.DeleteMessage(mainFlex.guildsTree.selectedChannelID, m.ID, ""); err != nil {
log.Println(err)
}
Expand Down

0 comments on commit 20fd9e3

Please sign in to comment.