Skip to content

Commit

Permalink
make checking perms before sending opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
starshine-sys committed Jun 2, 2021
1 parent aeef059 commit 4b32fb9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
6 changes: 0 additions & 6 deletions messageSend.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ func (m *MessageSend) Send() (msg *discord.Message, err error) {
}

func (m *MessageSend) send() (msg *discord.Message, err error) {
if m.checkPerms {
if !m.ctx.checkBotSendPerms(m.channel, m.Data.Embed != nil) {
return nil, ErrBotMissingPermissions
}
}

return m.ctx.State.SendMessageComplex(m.channel, m.Data)
}

Expand Down
4 changes: 2 additions & 2 deletions permCheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func (ctx *Context) checkOwner() bool {
return false
}

// checkBotSendPerms checks if the bot can send messages in a channel
func (ctx *Context) checkBotSendPerms(ch discord.ChannelID, e bool) bool {
// CheckBotSendPerms checks if the bot can send messages in a channel
func (ctx *Context) CheckBotSendPerms(ch discord.ChannelID, e bool) bool {
// if this is a DM channel we always have perms
if ctx.Channel.ID == ch && ctx.Message.GuildID == 0 {
return true
Expand Down
4 changes: 0 additions & 4 deletions reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ var (

// Send sends a message to the context channel
func (ctx *Context) Send(content string, embed *discord.Embed) (m *discord.Message, err error) {
if !ctx.checkBotSendPerms(ctx.Channel.ID, embed != nil) {
return nil, ErrBotMissingPermissions
}

return ctx.State.SendMessageComplex(ctx.Channel.ID, api.SendMessageData{
Content: content,
Embed: embed,
Expand Down

0 comments on commit 4b32fb9

Please sign in to comment.