Skip to content

Commit

Permalink
Merge pull request #27 from sustained/hotfix-util-try-delete
Browse files Browse the repository at this point in the history
fix: Fix issue with tryDelete in direct messages.
  • Loading branch information
sustained authored Oct 7, 2019
2 parents 565b269 + 39f204f commit a60e869
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/utils/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ import client from '../client'
export function tryDelete(msg, delay = 0) {
console.debug(`Attempting to delete msg #${msg.id}.`)

if (msg.channel.type === 'dm' && msg.author.id !== msg.client.user.id) {
console.debug('Cannot delete - is DM.')
return false
}

if (!msg.guild.me.hasPermission('MANAGE_MESSAGES')) {
console.debug('Cannot delete - lacking permissions.')
return false
}
if (msg.channel.type === 'dm') {
if (msg.author.id !== msg.client.user.id) {
console.debug('Cannot delete - is DM.')
return false
}
} else {
if (!msg.guild.me.hasPermission('MANAGE_MESSAGES')) {
console.debug('Cannot delete - lacking permissions.')
return false
}

if (msg.member.hasPermission('ADMINISTRATOR')) {
if (!msg.guild.me.hasPermission('ADMINISTRATOR')) {
console.debug('Cannot delete - user is admin but I am not.')
if (msg.member.hasPermission('ADMINISTRATOR')) {
if (!msg.guild.me.hasPermission('ADMINISTRATOR')) {
console.debug('Cannot delete - user is admin but I am not.')
}
}
}

Expand Down

0 comments on commit a60e869

Please sign in to comment.