Skip to content

Commit

Permalink
fix(message): return if the bot doesn't have SEND_MESSAGES permission
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Oct 13, 2021
1 parent 641c19a commit 2ec00ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module.exports = {
name: 'messageCreate',
once: false,
async execute(message, client) {
if (message.author.bot || message.author.system || message.type !== 'DEFAULT' && message.type !== 'REPLY' || !message.content) {
const { author, type } = message;
if (author.bot || author.system || type !== 'DEFAULT' && type !== 'REPLY' || !message.content || !message.channel.permissionsFor(client.user).has('SEND_MESSAGES')) {
return;
}
const database = client.db.prepare('SELECT * FROM guilds WHERE id = ?').get(message.guildId);
Expand All @@ -26,7 +27,7 @@ module.exports = {
return;
}

if (!client.commands.has(array[0]) || !message.channel.permissionsFor(client.user).has('SEND_MESSAGES')) {
if (!client.commands.has(array[0])) {
return;
}

Expand Down
6 changes: 5 additions & 1 deletion events/messageUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ module.exports = {
await newMessage.fetch();
}

if (newMessage.author.bot || newMessage.author.system || newMessage.type !== 'DEFAULT' && newMessage.type !== 'REPLY' || !newMessage.content) return;
const { author, type } = newMessage;
if (author.bot || author.system || type !== 'DEFAULT' && type !== 'REPLY' || !newMessage.content || !newMessage.channel.permissionsFor(client.user).has('SEND_MESSAGES')){
return;
}

const database = client.db.prepare('SELECT * FROM guilds WHERE id = ?').get(newMessage.guildId);
require('../detector/detector.js')(client, newMessage, database, true);
}
Expand Down

0 comments on commit 2ec00ed

Please sign in to comment.