You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
4.2 KiB
67 lines
4.2 KiB
const Discord = require('discord.js');
|
|
const chalk = require('chalk');
|
|
|
|
const wait = require('../util/wait');
|
|
|
|
const UserData = require('../models/user');
|
|
const AR = require('../models/ar');
|
|
|
|
module.exports = async (client, message) => {
|
|
if (message.author.bot) {return undefined;}
|
|
if (message.channel.type !== 'text' && message.channel.type !== 'dm') {return undefined;}
|
|
|
|
//if (message.channel.type == "text") {if (settings[message.guild.id]) {prefix = settings[message.guild.id].prefix;};};
|
|
|
|
if (message.guild && !message.member.permissions.has("SEND_MESSAGES")) {return undefined;}
|
|
|
|
let prefix = message.guild ? client.guildconfig.prefixes.has(message.guild.id) ? client.guildconfig.prefixes.get(message.guild.id) !== null ? client.guildconfig.prefixes.get(message.guild.id) : 'n?' : 'n?' : 'n?';
|
|
|
|
let msg = message.content.toLowerCase();
|
|
let mention = message.mentions.users.first();
|
|
let args = msg.startsWith(prefix)
|
|
? message.content.slice(prefix.length).trim().split(/\s+/g)
|
|
: msg.startsWith('<@!')
|
|
? message.content.slice(4 + client.user.id.length).trim().split(/\s+/g)
|
|
: message.content.slice(3 + client.user.id.length).trim().split(/\s+/g);
|
|
let cmd = args.shift().toLowerCase().trim();
|
|
|
|
if ([`<@${client.user.id}>`, `<@!${client.user.id}>`].includes(msg)) {
|
|
return message.channel.send(new Discord.MessageEmbed()
|
|
.setTitle(["Yep, that's me!", "^^ Hiya!", "Oh, hi there!", "Sure, what's up?", "How can I help!", "Natsuki is busy, but I can take a message for you!", "Teehee that's me!", "You were looking for Natsuki Tivastl, right?", "Sure! What's up?", "Pong!"][Math.floor(Math.random() * 10)])
|
|
.setDescription("My prefix here is `" + prefix + "`. Use `" + prefix + "help` to see what commands you can use.")
|
|
.setColor('c375f0'));
|
|
}
|
|
|
|
if (mention && message.guild) {require('../util/mention')(message, msg, args, cmd, prefix, mention, client);}
|
|
UserData.findOne({uid: message.author.id}).then(async (tu) => {
|
|
if (tu && tu.statusmsg.length && tu.statusclearmode === 'auto') {
|
|
tu.statusmsg = '';
|
|
tu.statustype = '';
|
|
tu.save();
|
|
require('../util/siftstatuses')(client, message.author.id, true);
|
|
message.reply('Hey there! You asked me to clear your status when you send a message next, so I went ahead and did that for you.').then(m => {m.delete({timeout: 5000});});
|
|
}});
|
|
|
|
if (client.misc.cache.ar.has(message.guild.id) && client.misc.cache.ar.get(message.guild.id).includes(msg.trim())) {
|
|
AR.findOne({gid: message.guild.id}).then(ar => {
|
|
if (ar && ar.triggers.length && ar.triggers.includes(msg.trim()) && Object.keys(ar.ars).includes(msg.trim())) {return message.channel.send(ar.ars[msg.trim()]);}
|
|
});
|
|
}
|
|
|
|
try {
|
|
if (msg.startsWith(prefix) || msg.startsWith(`<@${client.user.id}>`) || msg.startsWith(`<@!${client.user.id}>`)) {
|
|
let command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));
|
|
if (!command) {let trigger; for (trigger of client.responses.triggers) {if (await trigger[1](message, msg, args, cmd, prefix, mention, client)) {await client.responses.commands.get(trigger[0]).execute(message, msg, args, cmd, prefix, mention, client); break;}} return;}
|
|
message.channel.startTyping();
|
|
await wait(800);
|
|
message.channel.stopTyping();
|
|
if (command.meta && command.meta.guildOnly && !message.guild) {return message.channel.send("You must be in a server to use this command!");}
|
|
require('../util/oncommand')(message, msg, args, cmd, prefix, mention, client);
|
|
return command.execute(message, msg, args, cmd, prefix, mention, client);
|
|
}
|
|
let trigger; for (trigger of client.responses.triggers) {if (await trigger[1](message, msg, args, cmd, prefix, mention, client)) {await client.responses.commands.get(trigger[0]).execute(message, msg, args, cmd, prefix, mention, client); break;}}
|
|
} catch (e) {
|
|
let date = new Date; date = date.toString().slice(date.toString().search(":") - 2, date.toString().search(":") + 6);
|
|
console.error(`\n${chalk.red('[ERROR]')} >> ${chalk.yellow(`At [${date}] | In ${message.guild.name}\n`)}`, e);
|
|
}
|
|
}; |