forked from PartMan7/PartProfessor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscord.js
More file actions
executable file
·43 lines (42 loc) · 2.75 KB
/
discord.js
File metadata and controls
executable file
·43 lines (42 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
exports.handler = async message => {
if (message.author.bot) return;
if (message.channel.type === 'dm') client.channels.cache.get('782853501327900706').send(`<@${message.author.id}> [${message.author.username}#${message.author.id}]: ${message.content}`);
if (!message.content.startsWith(prefix) && message.mentions && message.mentions.users && message.mentions.users.has(client.user.id)) return message.channel.send(`Hi, I'm ${Bot.status.nickName}! I'm a bot by ${config.owner}. My command character is \`\`${prefix}\`\`.`);
if (!message.content.startsWith(prefix)) return require('./discord_chat.js').handle(message, Bot);
const admins = config.discordAdmins;
let args = message.content.substr(prefix.length).split(' '), commandName = toID(args.shift());
if (!commandName) return;
commandName = require('./data/ALIASES/discord.json')[commandName] || commandName;
try {
if (['eval', 'output'].includes(commandName)) {
if (!admins.includes(message.author.id)) return message.channel.send('ACCESS DENIED.').then(msg => msg.delete({timeout: 3000}));
let output = eval(args.join(' '));
switch (typeof output) {
case 'object': output = require('util').inspect(output);
case 'function': output = output.toString(); break;
}
return message.channel.send('```\n' + output + '```').catch(e => message.channel.send('```\n' + output.substr(0, 1970) + '```').catch(e => {
message.channel.send(e.message);
Bot.log(e);
}));
}
let dir = fs.readdirSync('./discord');
if (!dir.includes(commandName + '.js')) return message.channel.send("Doesn't look like that command exists...").then(msg => msg.delete({timeout: 3000}));
let commandFile = require(`./discord/${commandName}.js`);
if (commandFile.guildOnly &&
!(Array.isArray(commandFile.guildOnly) && commandFile.guildOnly.includes(message.guild.id)) &&
!(typeof commandFile.guildOnly === "string" && commandFile.guildOnly == message.guild.id) &&
message.guild.id !== '719076445699440700') return message.channel.send('Not meant to be used here.').then(msg => msg.delete({timeout: 3000}));
else if (commandFile.admin && !admins.includes(message.author.id)) return message.channel.send('Access denied.').then(msg => msg.delete({timeout: 3000}));
else if (message.type === 'dm') {
if (!commandFile.pm) return message.channel.send("This command isn't available in DMs, sorry...").then(msg => msg.delete({timeout: 3000}));
else if (typeof commandFile.pm === 'function') return commandFile.pm(args, message, Bot);
}
if (commandFile.pmOnly) return message.channel.send("This command is only available in DMs, sorry...").then(msg => msg.delete({timeout: 3000}));
else return commandFile.commandFunction(args, message, Bot);
} catch (e) {
message.channel.send(`Error: ${e.message}`);
Bot.log(e);
}
return;
}