Disable message input if client does not have permission to send messages
This commit is contained in:
parent
e43bb4d47c
commit
f58423bdaf
1 changed files with 13 additions and 2 deletions
|
|
@ -198,10 +198,21 @@ func (gt *GuildsTree) onSelected(n *tview.TreeNode) {
|
|||
return
|
||||
}
|
||||
|
||||
mainFlex.messagesText.SetTitle(gt.channelToString(*c))
|
||||
clientID := discordState.Ready().User.ID
|
||||
perms, err := discordState.Permissions(c.ID, clientID)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
if perms.Has(discord.PermissionSendMessages) {
|
||||
app.SetFocus(mainFlex.messageInput)
|
||||
} else {
|
||||
mainFlex.messageInput.SetDisabled(true)
|
||||
}
|
||||
|
||||
mainFlex.messagesText.SetTitle(gt.channelToString(*c))
|
||||
gt.selectedChannelID = ref
|
||||
app.SetFocus(mainFlex.messageInput)
|
||||
case nil: // Direct messages
|
||||
cs, err := discordState.Cabinet.PrivateChannels()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue