1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 13:03:18 +00:00
musix-oss/events/message.js

64 lines
3.1 KiB
JavaScript
Raw Normal View History

2019-09-15 06:18:33 +00:00
module.exports = {
name: 'message',
2019-10-10 13:43:04 +00:00
async execute(client, message, Discord) {
2019-09-15 06:18:33 +00:00
if (message.author.bot || !message.guild) return;
2019-10-10 13:43:04 +00:00
if (message.content.startsWith('->reset') && message.author.id === '360363051792203779') {
client.guilds.forEach(guild => {
2019-10-11 08:48:50 +00:00
client.global.db.guilds[guild.id] = {
prefix: ">",
2019-10-10 13:43:04 +00:00
defaultVolume: 5,
2019-10-11 08:48:50 +00:00
permissions: false,
2019-10-10 13:43:04 +00:00
};
});
return message.channel.send(':white_check_mark: Reset all guild settings!')
} else if (message.content.startsWith('->resetguildsettings') && message.author.id === '360363051792203779') {
2019-10-11 08:48:50 +00:00
client.global.db.guilds[message.guild.id] = {
prefix: ">",
2019-10-10 13:43:04 +00:00
defaultVolume: 5,
2019-10-11 08:48:50 +00:00
permissions: false,
2019-10-10 13:43:04 +00:00
};
}
2019-10-11 08:48:50 +00:00
let prefix = client.global.db.guilds[message.guild.id].prefix;
2019-10-10 13:43:04 +00:00
if (process.env.LOCALLYHOSTED === "true") {
prefix = "-";
if (message.author.id === "360363051792203779" || message.author.id === "384002606621655040") {
} else return;
}
const args = message.content.slice(prefix.length).split(' ');
2019-09-15 06:18:33 +00:00
if (message.mentions.users.first()) {
2019-10-10 13:43:04 +00:00
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}\`.`);
2019-09-15 06:18:33 +00:00
}
2019-10-11 08:48:50 +00:00
if (!message.content.startsWith(prefix) || message.guild.id !== '583597555095437312') return;
2019-09-15 06:18:33 +00:00
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';
}
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 {
2019-10-10 13:43:04 +00:00
command.execute(message, args, client, Discord, prefix);
2019-09-15 06:18:33 +00:00
} catch (error) {
2019-10-10 13:43:04 +00:00
message.reply(`:x: there was an error trying to execute that command! Please contact support with \`${prefix}bug\`!`);
2019-09-15 06:18:33 +00:00
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);
}
}
2019-10-10 13:43:04 +00:00
}