eximiabots-radiox/client/events/msg.js

28 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-03-02 19:38:42 +00:00
module.exports = {
name: 'message',
async execute(client, msg, Discord) {
if (msg.author.bot || !msg.guild) return;
2020-03-08 14:22:00 +00:00
let prefix = client.config.prefix;
if(msg.mentions.members.first()){
if(msg.mentions.members.first().user.id === client.user.id){
prefix = "<@!" + client.user.id + "> ";
}
}
2020-03-02 19:38:42 +00:00
const args = msg.content.slice(prefix.length).split(' ');
if (!msg.content.startsWith(prefix)) return;
if (!args[0]) return;
const commandName = args[0].toLowerCase();
if (commandName === 'none') return;
2020-03-02 19:38:42 +00:00
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)) || client.commandAliases.get(commandName);
if (!command && msg.content !== `${prefix}`) return;
2020-03-12 09:59:05 +00:00
const permissions = msg.channel.permissionsFor(msg.client.user);
2020-03-12 22:53:23 +00:00
if (!permissions.has('EMBED_LINKS')) return msg.channel.send(client.messages.noPermsEmbed);
2020-03-12 09:59:05 +00:00
try {
command.execute(msg, args, client, Discord, command);
2020-03-12 09:59:05 +00:00
} catch (error) {
2020-03-12 22:53:23 +00:00
msg.reply(client.messages.runningCommandFailed);
2020-03-12 09:59:05 +00:00
console.error(error);
}
2020-03-02 19:38:42 +00:00
}
}