1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 03:33:17 +00:00
musix-oss/events/message.js
2019-10-27 18:06:48 +02:00

68 lines
3.2 KiB
JavaScript

module.exports = {
name: 'message',
async execute(client, message, Discord) {
if (message.author.bot || !message.guild) return;
if (message.content === '->reset' && message.author.id === '360363051792203779') {
client.guilds.forEach(guild => {
client.global.db.guilds[guild.id] = {
prefix: ">",
defaultVolume: 5,
permissions: false,
premium: false,
dj: false,
djrole: null
};
});
return message.channel.send(':white_check_mark: Reset all guild settings!')
} else if (message.content === '->resetguildsettings' && message.author.id === '360363051792203779') {
client.global.db.guilds[message.guild.id] = {
prefix: ">",
defaultVolume: 5,
permissions: false,
premium: false,
dj: false,
djrole: null
};
}
let prefix = client.global.db.guilds[message.guild.id].prefix;
const args = message.content.slice(prefix.length).split(' ');
if (message.mentions.users.first()) {
if (message.mentions.users.first().id === '607266889537945605' && args[1] === 'help') return client.commands.get('help').execute(message, args, client, Discord, prefix, client);
if (message.mentions.users.first().id === '607266889537945605' && args[1] === 'prefix') return message.channel.send(`My prefix here is: \`${prefix}\`.`);
}
if (!message.content.startsWith(prefix)) return;
if (!args[0]) return;
let commandName = args[0].toLowerCase();
if (commandName === `p`) {
commandName = 'play';
}
if (commandName === 'q') {
commandName = 'queue';
}
if (commandName === 's') {
commandName = 'skip';
}
if (commandName === 'np') {
commandName = 'nowplaying';
}
if (commandName === 'rm') {
commandName = 'remove';
}
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
const permissions = message.channel.permissionsFor(message.client.user);
if (!permissions.has('EMBED_LINKS')) return message.channel.send(':x: I cannot send embeds (Embed links), make sure I have the proper permissions!');
if (!command && message.content !== `${prefix}`) return;
try {
command.execute(message, args, client, Discord, prefix);
} catch (error) {
message.reply(`:x: there was an error trying to execute that command! Please contact support with \`${prefix}bug\`!`);
const embed = new Discord.RichEmbed()
.setTitle(`Musix ${error.toString()}`)
.setDescription(error.stack.replace(/at /g, '**at **'))
.setColor('#b50002');
client.fetchUser('360363051792203779').then(user => user.send(embed)).catch(console.error);
client.channels.get('634718645188034560').send(embed);
}
}
}