Skip to content

Commit

Permalink
feat: send messages check
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Sep 28, 2021
1 parent 775f410 commit 629e1b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ module.exports = {
name: 'messageCreate',
once: false,
async execute(message, client) {
if (message.author.bot || message.author.system || message.type !== 'DEFAULT' || !message.content) return;
if (message.author.bot || message.author.system || message.type !== 'DEFAULT' || !message.content) {
return;
}
const database = client.db.prepare('SELECT * FROM guilds WHERE id = ?').get(message.guildId);
message.prefix = database?.prefix ?? client.prefix;

const array = message.content.replace(message.prefix, '').split(' ');
const args = array.slice(1);

const badLetterDetected = await require('../detector/detector.js')(client, message, database);
if (badLetterDetected || !client.commands.has(array[0]) || !message.content.startsWith(message.prefix)) return;
if (badLetterDetected || !client.commands.has(array[0]) || !message.content.startsWith(message.prefix) || !message.channel.permissionsFor(client.user).has('SEND_MESSAGES')) {
return;
}

const command = client.commands.get(array[0]);
if (!message.member.permissions.has(command.permissions ?? 0n)) {
Expand Down

0 comments on commit 629e1b7

Please sign in to comment.