fix(ui): reply action not displayed for DM channels (#237)
This commit is contained in:
parent
99a7bbf2ae
commit
4f4d03f90f
3 changed files with 10 additions and 4 deletions
|
|
@ -35,7 +35,7 @@ func newActionsView(c *Core, m *discord.Message) *ActionsView {
|
|||
})
|
||||
|
||||
// If the client user has the `SEND_MESSAGES` permission, add "Reply" and "Mention Reply" actions.
|
||||
if hasPermission(c.State, c.ChannelsView.selectedChannel.ID, discord.PermissionSendMessages) {
|
||||
if channelIsInDMCategory(c.ChannelsView.selectedChannel) || hasPermission(c.State, c.ChannelsView.selectedChannel.ID, discord.PermissionSendMessages) {
|
||||
v.AddItem("Reply", "", 'r', v.replyAction)
|
||||
v.AddItem("Mention Reply", "", 'R', v.mentionReplyAction)
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ func newActionsView(c *Core, m *discord.Message) *ActionsView {
|
|||
}
|
||||
|
||||
// If the client user has the `MANAGE_MESSAGES` permission, add a new action to delete the message.
|
||||
if hasPermission(c.State, c.ChannelsView.selectedChannel.ID, discord.PermissionManageMessages) {
|
||||
if channelIsInDMCategory(c.ChannelsView.selectedChannel) || hasPermission(c.State, c.ChannelsView.selectedChannel.ID, discord.PermissionManageMessages) {
|
||||
v.AddItem("Delete", "", 'd', v.deleteAction)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ func (v *InputView) sendMessage() *tcell.EventKey {
|
|||
_, m := findMessageByID(ms, discord.MessageID(mID))
|
||||
d := api.SendMessageData{
|
||||
Content: t,
|
||||
Reference: m.Reference,
|
||||
Reference: &discord.MessageReference{
|
||||
MessageID: m.ID,
|
||||
},
|
||||
AllowedMentions: &api.AllowedMentions{RepliedUser: option.False},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func channelToString(c discord.Channel) string {
|
|||
for i, r := range c.DMRecipients {
|
||||
rps[i] = r.Username + "#" + r.Discriminator
|
||||
}
|
||||
|
||||
|
||||
repr = strings.Join(rps, ", ")
|
||||
}
|
||||
default:
|
||||
|
|
@ -62,6 +62,10 @@ func findMessageByID(ms []discord.Message, mID discord.MessageID) (int, *discord
|
|||
return -1, nil
|
||||
}
|
||||
|
||||
func channelIsInDMCategory(c *discord.Channel) bool {
|
||||
return c.Type == discord.DirectMessage || c.Type == discord.GroupDM
|
||||
}
|
||||
|
||||
func hasPermission(s *state.State, cID discord.ChannelID, p discord.Permissions) bool {
|
||||
perm, err := s.Permissions(cID, s.Ready().User.ID)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue