Skip to content

Commit

Permalink
fix(prefix): only check permissions when no prefix was provided
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Oct 30, 2021
1 parent d5f075f commit 6e90853
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions commands/bot/prefix.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module.exports = {
name: 'prefix',
description: 'Manaqe the bot\'s prefix',
permissions: ['MANAGE_MESSAGES'],
async execute(client, message, args) {
const database = client.db.prepare('SELECT prefix FROM guilds WHERE id = ?').get(message.guildId);
const statement = database ? 'UPDATE guilds SET prefix = @prefix WHERE id = @id' : 'INSERT INTO guilds (id, prefix) VALUES (@id, @prefix)';
const badLetters = require('../../detector/detection.json').join('');
const detector = RegExp(`[${badLetters}]`, 'giu');

if (!args.join(' ')) {
if (!args.length) {
return message.channel.send({
embeds: [{
title: 'Prefix',
Expand All @@ -18,6 +17,10 @@ module.exports = {
});
}

if (!message.member.permissions.has('MANAGE_MESSAGES')) {
return message.channel.send('You need the `MANAGE_MESSAGES` permission to chanqe the prefix');
}

if (args.join(' ').length >= 10 || detector.test(args.join(' '))) {
return message.channel.send({
embeds: [{
Expand Down

0 comments on commit 6e90853

Please sign in to comment.