Compare commits
6 Commits
dfc1674bad
...
a8660cfb96
Author | SHA1 | Date |
---|---|---|
Emily | a8660cfb96 | |
Emily | 9e47046c7b | |
Emily | d1a4b2cf5c | |
Emily | 003712fe7f | |
Emily | 1f2fd34ac5 | |
Emily | b561f80835 |
|
@ -1,22 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: '',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
|
||||
}
|
||||
};
|
|
@ -1,95 +0,0 @@
|
|||
const prettified = require ('../../assets/categories.json');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'meta :P',
|
||||
arguments: '[command/category]',
|
||||
details: 'details',
|
||||
examples: 'examples'
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
const commands = client.commands;
|
||||
const categories = [];
|
||||
|
||||
commands.forEach(cmd => {
|
||||
if (!categories.includes(cmd.category)) {
|
||||
if (cmd.category === 'Developer' && !client.config.ownerIDs.includes(message.author.id)) return;
|
||||
categories.push(cmd.category);
|
||||
}
|
||||
});
|
||||
|
||||
if (!args[0]) {
|
||||
const embed = new client.MessageEmbed();
|
||||
embed.setTitle('Help & Commands');
|
||||
embed.setColor(client.functions.embedColor(message.guild));
|
||||
embed.setDescription(
|
||||
`
|
||||
» Use \`${message.prefix}help [category]\` to get basic information on all commands in the category.
|
||||
» Use \`${message.prefix}help [command]\` to get full information on a specific command.
|
||||
» [Click here](https://discord.gg/HCF8mdv) to join my Discord server if you need help, or just want to hang out!
|
||||
» [Click here](https://discord.com/oauth2/authorize?client_id=${client.user.id}&permissions=2134240503&scope=bot) to invite me to your server!
|
||||
\n**News:**
|
||||
A massive update has just been released! Lots of commands and features have been added or redone and my code has been rewritten to use lots of cool new stuff. To view the full changelog, run \`changelog\`
|
||||
`
|
||||
);
|
||||
categories.forEach(category => {
|
||||
embed.addField(`${prettified[category].emoji} ${category}`, `*${prettified[category].description}*\n${client.commands.filter(cmd => cmd.category === category).length} commands`, true);
|
||||
});
|
||||
embed.setFooter('<> = required, / = either/or, [] = optional');
|
||||
|
||||
return message.channel.send({ embeds: [embed] });
|
||||
}
|
||||
|
||||
const cat = args[0].toProperCase();
|
||||
const cmd = args[0].toLowerCase();
|
||||
|
||||
if (categories.includes(cat)) {
|
||||
let cmds = '';
|
||||
const filteredCmds = client.commands.filter(cmd => cmd.category === cat);
|
||||
|
||||
filteredCmds.forEach(cmd => {
|
||||
let params = '';
|
||||
if (cmd.help.arguments.length > 0) params = '`' + cmd.help.arguments + '`';
|
||||
cmds += `**${message.prefix + cmd.name}** ${params} ✦ ${cmd.help.description}\n`;
|
||||
});
|
||||
|
||||
const embed = new client.MessageEmbed()
|
||||
.setTitle(prettified[cat].emoji + ' ' + cat)
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.setDescription(cmds)
|
||||
.setFooter('<> = required, / = either/or, [] = optional');
|
||||
|
||||
return message.channel.send({ embeds: [embed] });
|
||||
}
|
||||
|
||||
if (client.commands.has(cmd) || client.aliases.has(cmd)) {
|
||||
const command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));
|
||||
const embed = new client.MessageEmbed()
|
||||
.setTitle(prettified[command.category].emoji + ' ' + command.category + ' -> ' + command.name.toProperCase())
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.setDescription(command.help.description)
|
||||
.addField('Format:', `\`${message.prefix + command.name} ${command.help.arguments}`.trim() + '`');
|
||||
if (command.help.details.length > 0) embed.addField('Parameters:', command.help.details);
|
||||
if (command.help.examples.length > 0) embed.addField('Examples', command.help.examples);
|
||||
if (command.aliases.length > 0) embed.addField('Aliases:', '`' + command.aliases.join('`, `') + '`');
|
||||
if (command.userPerms.length > 0) embed.addField('User permissions:', command.userPerms.join(', '), true);
|
||||
if (command.botPerms.length > 0) embed.addField('Bot permissions:', command.botPerms.join(', '), true);
|
||||
embed.addField('Cooldown:', `${command.cooldown / 1000} seconds`, true);
|
||||
embed.setFooter('<> = required, / = either/or, [] = optional');
|
||||
return message.channel.send({ embeds: [embed] });
|
||||
}
|
||||
|
||||
return message.channel.send(`${client.config.emojis.userError} ${cmd} doesn't appear to be a command, alias, or category. Are you sure you spelt it right?`);
|
||||
}
|
||||
};
|
|
@ -1,27 +0,0 @@
|
|||
const replies = require('../../assets/replies.json');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'Test response time between Woomy and Discord.',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
message.channel.send(replies.ping.random())
|
||||
.then(m => {
|
||||
m.edit(`${m.content} \`roundtrip: ${m.timestamp - message.timestamp}ms | websocket: ${message.guild.shard.latency}ms\``);
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: '',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) {
|
||||
|
||||
}
|
||||
};
|
|
@ -1,119 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = ['administrator'],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'Add, remove or list users on the blocklist for this server. User\'s on the blocklist cannot use my commands.',
|
||||
arguments: '<add | remove | list> <user>',
|
||||
details: '',
|
||||
examples: 'blocklist list\nblocklist add @Veemo\nblocklist remove emily'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, [action, ...user], data) {
|
||||
if (!action || action.toLowerCase() === 'list') {
|
||||
const list = [];
|
||||
for (const userID of data.guild.blocklist) {
|
||||
const user = await client.users.fetch(userID);
|
||||
list.push(`${user.username}#${user.discriminator}`);
|
||||
}
|
||||
|
||||
if (list.length === 0) return message.channel.send('The server blocklist is currently empty. Use `blocklist add <user>` to add people to the blocklist!');
|
||||
|
||||
const embed = new client.MessageEmbed()
|
||||
.setTitle('Users on blocklist: ' + data.guild.blocklist.length)
|
||||
.setDescription('```' + list.join(', ') + '```')
|
||||
.setColor(client.functions.embedColor(message.guild));
|
||||
|
||||
message.channel.send({ embeds: [embed] });
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
action = action.toLowerCase();
|
||||
|
||||
if (action !== 'add' & action !== 'remove') {
|
||||
return message.channel.send(`${client.config.emojis.userError} You didn't specify a valid action. Usage: \`${this.help.usage}\``);
|
||||
}
|
||||
|
||||
if (!user) return message.channel.send(
|
||||
`${client.config.emojis.userError} You didn't specify a user. Usage: \`${message.prefix + this.help.usage}\``
|
||||
);
|
||||
|
||||
let member;
|
||||
|
||||
if (message.mentions.length > 0) {
|
||||
member = await message.guild.members.fetch(message.mentions[0].id);
|
||||
} else {
|
||||
member = await client.functions.validateUserID(message.guild, user[0]);
|
||||
|
||||
if (!member) {
|
||||
member = await message.guild.searchMembers(user.join(' '), 2);
|
||||
|
||||
if (member.length === 0) return message.channel.send(
|
||||
`${client.config.emojis.userError} No users found. Check for mispellings, or ping the user instead.`
|
||||
);
|
||||
|
||||
if (member.length > 1) return message.channel.send(
|
||||
`${client.config.emojis.userError} Found more than one user, try refining your search or pinging the user instead.`
|
||||
);
|
||||
|
||||
member = member[0];
|
||||
}
|
||||
}
|
||||
|
||||
const blocklist = data.guild.blocklist;
|
||||
|
||||
if (action === 'add') {
|
||||
if (member.id === message.guild.ownerID) return message.channel.send(
|
||||
`${client.config.emojis.userError} You can't block the owner, silly!`
|
||||
);
|
||||
|
||||
if (client.functions.highestRole(member).position >= client.functions.highestRole(message.member).position && message.member.id !== message.guild.ownerID) {
|
||||
return message.channel.send(`${client.config.emojis.userError} This user has a higher role than you, you can't add them to the blocklist!`);
|
||||
}
|
||||
|
||||
if (blocklist.includes(member.id)) return message.channel.send(
|
||||
`${client.config.emojis.userError} This user is already on the blocklist, you can't add them twice!`
|
||||
);
|
||||
|
||||
blocklist.push(member.id);
|
||||
|
||||
client.db.updateGuild(message.guild.id, 'blocklist', blocklist).then(() => {
|
||||
message.channel.send(`${client.config.emojis.success} Added \`${member.username}#${member.discriminator}\` to the blocklist.`);
|
||||
}).catch(error => {
|
||||
client.logger.error('GUILD_UPDATE_ERROR', error);
|
||||
message.channel.send(`${client.config.emojis.botError} An error occured while adding this user to the blocklist, please try again! **Error:** ${error}`);
|
||||
}) ;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === 'remove') {
|
||||
if (client.functions.highestRole(member).position >= client.functions.highestRole(message.member).position && message.member.id !== message.guild.ownerID) {
|
||||
return message.channel.send(`${client.config.emojis.userError} This user has a higher role than you, you can't remove them to the blocklist!`);
|
||||
}
|
||||
|
||||
if (!blocklist.includes(member.id)) return message.channel.send(
|
||||
`${client.config.emojis.userError} This user isn't on the blocklist.`
|
||||
);
|
||||
|
||||
blocklist.remove(member.id);
|
||||
|
||||
client.db.updateGuild(message.guild.id, 'blocklist', blocklist).then(() => {
|
||||
message.channel.send(`${client.config.emojis.success} Removed \`${member.username}#${member.discriminator}\` from the blocklist.`);
|
||||
}).catch(error => {
|
||||
client.logger.error('GUILD_UPDATE_ERROR', error);
|
||||
message.channel.send(`${client.config.emojis.botError} An error occured while removing this user from the blocklist, please try again! **Error:** ${error}`);
|
||||
}) ;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,95 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = ['disabled'],
|
||||
this.userPerms = ['administrator'],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'description',
|
||||
arguments: '[command/category]',
|
||||
details: '`command/category` - choose whether to disable a command or a category.',
|
||||
examples: 'examples'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) {
|
||||
const essential = {
|
||||
categories: ['Configuration', 'Developer'],
|
||||
commands: ['help']
|
||||
};
|
||||
|
||||
if (!args[0] || args[0].toLowerCase() === 'list') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args[1]) return message.channel.send(
|
||||
`${client.config.emojis.userError} You didn't specify what command/category to disable. Usage: \`${this.help.usage}\``
|
||||
);
|
||||
|
||||
if (args[0].toLowerCase() === 'command' || args[0].toLowerCase() === 'cmd') {
|
||||
const disabled = data.guild.disabledcommands;
|
||||
|
||||
let command;
|
||||
|
||||
if (client.commands.has(args[1])) {
|
||||
command = client.commands.get(args[1]);
|
||||
} else if (client.aliases.has(args[1])) {
|
||||
command = client.commands.get(client.aliases.get(args[1]));
|
||||
}
|
||||
|
||||
if (!command) return message.channel.send(
|
||||
`${client.config.emojis.userError} ${args[1]} isn't a command or an alias, are you sure you spelt it correctly?`
|
||||
);
|
||||
|
||||
if (essential.commands.includes(command.name) || essential.categories.includes(command.category)) {
|
||||
return message.channel.send(
|
||||
`${client.config.emojis.userError} This command is essential and cannot be disabled. Sorry!`
|
||||
);
|
||||
}
|
||||
|
||||
if (disabled.includes(command.name)) return message.channel.send(
|
||||
`${client.config.emojis.userError} This command is already disabled.`
|
||||
);
|
||||
|
||||
disabled.push(command.name);
|
||||
|
||||
await client.db.updateGuild(message.guild.id, 'disabledcommands', disabled);
|
||||
|
||||
return message.channel.send(
|
||||
`${client.config.emojis.success} Added **${args[1]}** to the list of disabled commands for this server.`
|
||||
);
|
||||
}
|
||||
|
||||
if (args[0].toLowerCase() === 'category' || args[0].toLowerCase() === 'cat') {
|
||||
const disabled = data.guild.disabledcommands;
|
||||
|
||||
let command;
|
||||
|
||||
if (client.commands.has(args[1])) {
|
||||
command = client.commands.get(args[1]);
|
||||
} else if (client.aliases.has(args[1])) {
|
||||
command = client.commands.get(client.aliases.get(args[1]));
|
||||
}
|
||||
|
||||
if (!command) return message.channel.send(
|
||||
`${client.config.emojis.userError} ${args[1]} isn't a category, are you sure you spelt it correctly?`
|
||||
);
|
||||
|
||||
if (!disabled.includes(command.name)) return message.channel.send(
|
||||
`${client.config.emojis.userError} This category isn't disabled.`
|
||||
);
|
||||
|
||||
disabled.remove(command.name);
|
||||
|
||||
await client.db.updateGuild(message.guild.id, 'disabledcommands', disabled);
|
||||
|
||||
return message.channel.send(
|
||||
`${client.config.emojis.success} Added **${args[1]}** to the list of disabled category for this server!`
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: '',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
|
||||
}
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: '',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
|
||||
}
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: '',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
|
||||
}
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: '',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
|
||||
}
|
||||
};
|
|
@ -1,32 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 5000,
|
||||
this.help = {
|
||||
description: 'Sets your own personal prefix for woomy, that works across all the servers you\'re in!',
|
||||
arguments: '[new prefix]',
|
||||
details: '',
|
||||
examples: 'userprefix w! - sets your personal prefix to woomy'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) {
|
||||
if (!args[0]) {
|
||||
return message.channel.send(
|
||||
`Your prefix for Woomy is currently: \`${data.user.prefix}\``
|
||||
);
|
||||
}
|
||||
|
||||
await client.db.updateUser(message.author.id, 'prefix', args[0]);
|
||||
|
||||
message.channel.send(
|
||||
`${client.config.emojis.success} Your personal prefix has been set to: \`${args[0]}\``
|
||||
);
|
||||
}
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: '',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
|
||||
}
|
||||
};
|
|
@ -1,39 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = true,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 0,
|
||||
this.help = {
|
||||
description: 'Evalutes and executes JavaScript code.',
|
||||
arguments: '<code>',
|
||||
details: '',
|
||||
examples: 'eval this.client.deleteCapitalism()'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
const code = args.join(' ');
|
||||
try {
|
||||
const evaled = eval(code);
|
||||
const clean = await client.functions.clean(evaled);
|
||||
const MAX_CHARS = 3 + 2 + clean.length + 3;
|
||||
if (MAX_CHARS > 2000) {
|
||||
return message.channel.send(undefined, { file: Buffer.from(clean), name: 'EVAL_SUCCESS.js' });
|
||||
}
|
||||
message.channel.send(`\`\`\`js\n${clean}\n\`\`\``);
|
||||
} catch (err) {
|
||||
const e = await client.functions.clean(err);
|
||||
const MAX_CHARS = 3 + 2 + e.length + 3;
|
||||
if (MAX_CHARS > 2000) {
|
||||
return message.channel.send(undefined, { file: Buffer.from(e), name: 'EVAL_ERROR.txt' });
|
||||
}
|
||||
|
||||
message.channel.send(`\`\`\`xl\n${e}\n\`\`\``);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,24 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = true,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 0,
|
||||
this.help = {
|
||||
description: 'Reloads all commands and event modules.',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: '',
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
client.commandLoader.reloadCommands();
|
||||
client.eventLoader.reloadEventModules();
|
||||
message.channel.send('All commands and event modules have been reloaded!');
|
||||
}
|
||||
};
|
|
@ -1,33 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
const exitQuotes = require('../../assets/exitQuotes.json');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = true,
|
||||
this.aliases = ['reboot'],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 0,
|
||||
this.help = {
|
||||
description: 'Restarts Woomy.',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
client.logger.success('RESTART', 'Restart command received. ' + exitQuotes.random());
|
||||
client.disconnect();
|
||||
client.functions.wait();
|
||||
|
||||
fetch('https://gamecp.apex.to/api/client/servers/1fc76afa-9a4d-497b-983a-a898795ab5b5/power', {
|
||||
method: 'post',
|
||||
body: JSON.stringify({ 'signal': 'restart' }),
|
||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${client.config.server}`, 'User-Agent': client.config.userAgent }
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,46 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = ['color'],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'Shows you colours that can be random, a hex code or generated from the words you type into the command.',
|
||||
arguments: '[hexcode/text]',
|
||||
details: '',
|
||||
examples: '`colour` - generates a random colour\n`colour #ee79ff` - Displays the colour of this hexcode\n`colour alpaca` - Generates a colour from the word alpaca'
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
let colour;
|
||||
|
||||
if (!args[0]) {
|
||||
colour = client.functions.randomColour();
|
||||
} else if (args[0].match(/#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)) {
|
||||
colour = args[0];
|
||||
} else {
|
||||
let hash = 0;
|
||||
const string = args.join(' ');
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
hash = string.charCodeAt(i) + ((hash << 5) - hash);
|
||||
}
|
||||
colour = '#';
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const value = (hash >> (i * 8)) & 0xFF;
|
||||
colour += ('00' + value.toString(16)).substr(-2);
|
||||
}
|
||||
}
|
||||
|
||||
const embed = new client.MessageEmbed()
|
||||
.setTitle(colour)
|
||||
.setColor(colour)
|
||||
.setImage(`https://fakeimg.pl/256x256/${colour.replace('#', '')}/?text=%20`);
|
||||
|
||||
message.channel.send({ embeds: [embed] });
|
||||
}
|
||||
};
|
|
@ -1,39 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'Sends you a strip from the best comic ever',
|
||||
arguments: '[daily]',
|
||||
details: '',
|
||||
examples: '`garfield` - sends a random garfield comic strip\n`garfield daily` - sends the daily strip'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
let date = 'xxxx';
|
||||
if (args[0] && args[0].toLowerCase() === 'daily') date = new Date();
|
||||
const editMessage = await message.channel.send(`${client.config.emojis.loading} Please wait...`);
|
||||
fetch('`https://garfield-comics.glitch.me/`~SRoMG/?date=' + date, { headers: { 'User-Agent': client.config.userAgent }})
|
||||
.then(res => res.json())
|
||||
.then(json => {
|
||||
const embed = new client.MessageEmbed()
|
||||
.setTitle(`${json.data.name} (No. ${json.data.number})`)
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.setURL('https://www.mezzacotta.net/garfield/?comic=' + json.data.number)
|
||||
.setImage(json.data.image.src);
|
||||
editMessage.edit({ embeds: [embed] });
|
||||
})
|
||||
.catch(err => {
|
||||
editMessage.edit(`${client.config.emojis.botError} An error has occurred: ${err}`);
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,31 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'Generates a random (and likely terrible) inspirational quote.',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: null
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
const editMessage = await message.channel.send(`${client.config.emojis.loading} Please wait...`);
|
||||
try {
|
||||
fetch('http://inspirobot.me/api?generate=true', { headers: { 'User-Agent': client.config.userAgent }})
|
||||
.then(res => res.text())
|
||||
.then(body => editMessage.edit(body));
|
||||
} catch (err) {
|
||||
editMessage.edit(`${client.config.emojis.botError} An error has occurred: ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: '',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
|
||||
}
|
||||
};
|
|
@ -1,85 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'Get data on a Pokemon ability.',
|
||||
arguments: '<ability>',
|
||||
details: '',
|
||||
examples: '`ability intimidate`\n`ability moxie`'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
if (!args[0]) return message.channel.send(
|
||||
`${client.config.emojis.userError} You didn't give me an ability to look up!`
|
||||
);
|
||||
|
||||
const editMessage = await message.channel.send(`${client.config.emojis.loading} Please wait...`);
|
||||
|
||||
const query = args.join(' ').toLowerCase();
|
||||
|
||||
fetch('https://graphqlpokemon.favware.tech/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': client.config.userAgent
|
||||
},
|
||||
body: JSON.stringify({ query: `
|
||||
{
|
||||
getAbilityDetailsByFuzzy(ability: "${query}") {
|
||||
name
|
||||
desc
|
||||
shortDesc
|
||||
bulbapediaPage
|
||||
serebiiPage
|
||||
smogonPage
|
||||
isFieldAbility
|
||||
}
|
||||
}
|
||||
`})
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
if (json.errors) {
|
||||
json.errors.forEach(error => {
|
||||
if (error.message.startsWith('Failed to get data for ability')) {
|
||||
editMessage.edit(
|
||||
`${client.config.emojis.userError} I couldn't find any abilities with names similar to ${query}. Check your spelling, maybe?`
|
||||
);
|
||||
} else {
|
||||
client.logger.error('POKEMON_API_ERROR', error.message);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const ability = json.data.getAbilityDetailsByFuzzy;
|
||||
|
||||
let fieldEffects = '';
|
||||
if (ability.isFieldAbility) {
|
||||
fieldEffects = ` Outside of battle, ${ability.isFieldAbility}`;
|
||||
}
|
||||
|
||||
const embed = new client.MessageEmbed()
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.setTitle(ability.name.toProperCase());
|
||||
if (ability.desc) {
|
||||
embed.setDescription(ability.desc + fieldEffects);
|
||||
} else {
|
||||
embed.setDescription(ability.shortDesc + fieldEffects);
|
||||
}
|
||||
embed.addField('External Resources:', `[Bulbapedia](${ability.bulbapediaPage}) • [Serebii](${ability.serebiiPage}) • [Smogon](${ability.smogonPage})`);
|
||||
editMessage.edit({ content: null, embeds: [embed] });
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,140 +0,0 @@
|
|||
const { typeArray, colours } = require('../../assets/pokemon.json');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = ['type', 'typematchup'],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 5000,
|
||||
this.help = {
|
||||
description: 'Get the strengths and weaknesses of a pokemon type/type combination',
|
||||
arguments: '<pokemon/type> [type2]',
|
||||
details: 'The type2 argument is only needed if you are submitting two types, not a pokemon or singular type.',
|
||||
examples: '`effective ghost dragon`\n`effective ribombee`'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
if (!args[0]) return message.channel.send(
|
||||
`${client.config.emojis.userError} You didn't give me a pokemon or type combination to look up! Usage: \`${message.prefix + this.name + ' ' + this.help.arguments}\``
|
||||
);
|
||||
|
||||
const editMessage = await message.channel.send(`${client.config.emojis.loading} Please wait...`);
|
||||
|
||||
let types;
|
||||
|
||||
if (!typeArray.includes(args[0].toProperCase())) {
|
||||
const res = await fetch('https://graphqlpokemon.favware.tech/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': client.config.userAgent
|
||||
},
|
||||
body: JSON.stringify({ query: `
|
||||
{
|
||||
getPokemonDetailsByFuzzy(pokemon: "${args.join(' ').toLowerCase()}") {
|
||||
types
|
||||
}
|
||||
}
|
||||
`})
|
||||
});
|
||||
const json = await res.json();
|
||||
if (json.errors) {
|
||||
json.errors.forEach(error => {
|
||||
if (error.message.startsWith('No Pokémon found')) {
|
||||
message.channel.send(
|
||||
`${client.config.emojis.userError} I couldn't find any Pokemon with names similar to ${args.join(' ').toLowerCase()}. Check your spelling, maybe?`
|
||||
);
|
||||
} else {
|
||||
client.logger.error('MATCHUP_API_ERROR', error.message);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
types = json.data.getPokemonDetailsByFuzzy.types.map(type => type.toLowerCase());
|
||||
} else {
|
||||
types = args.map(type => type.toLowerCase());
|
||||
}
|
||||
|
||||
fetch('https://graphqlpokemon.favware.tech/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ query: `
|
||||
{
|
||||
getTypeMatchup(types: [${types.join(', ')}]) {
|
||||
attacking { doubleEffectiveTypes effectiveTypes normalTypes resistedTypes doubleResistedTypes effectlessTypes }
|
||||
defending { doubleEffectiveTypes effectiveTypes normalTypes resistedTypes doubleResistedTypes effectlessTypes }
|
||||
}
|
||||
}
|
||||
`})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(json => {
|
||||
if (json.errors) {
|
||||
json.errors.forEach(error => {
|
||||
if (error.message.includes('does not exist in "Types')) {
|
||||
message.channel.send(
|
||||
`${client.config.emojis.userError} One or more of the types you gave me are invalid. Check your spelling, maybe?`
|
||||
);
|
||||
} else {
|
||||
client.logger.error('MATCHUP_FETCH_ERROR', error.message);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const typeMatchup = json.data.getTypeMatchup;
|
||||
|
||||
let effectless = '';
|
||||
if (typeMatchup.attacking.effectlessTypes.length > 0) effectless = `
|
||||
**Doesn't effect:**
|
||||
${typeMatchup.attacking.effectlessTypes.map(type => `\`${type.toProperCase()}\``).join(' ')}
|
||||
`;
|
||||
|
||||
let immune = '';
|
||||
if (typeMatchup.defending.effectlessTypes.length > 0) immune = `
|
||||
**Immunities:**
|
||||
${typeMatchup.defending.effectlessTypes.map(type => `\`${type.toProperCase()}\``).join(' ')}
|
||||
`;
|
||||
|
||||
const embed = new client.MessageEmbed()
|
||||
.setColor(colours[types[0].toProperCase()])
|
||||
.setTitle('Type effectiveness of ' + types.map(type => type.toProperCase()).join(' and '))
|
||||
.addField('Offensive:', `
|
||||
**Super-effective:**
|
||||
${this.parseEffectiveTypes(typeMatchup.attacking.effectiveTypes, typeMatchup.attacking.doubleEffectiveTypes)}
|
||||
**Not very effective:**
|
||||
${this.parseResistedTypes(typeMatchup.attacking.resistedTypes, typeMatchup.attacking.doubleResistedTypes)}${effectless}
|
||||
`)
|
||||
.addField('Defensive:', `
|
||||
**Weaknesses:**
|
||||
${this.parseEffectiveTypes(typeMatchup.defending.effectiveTypes, typeMatchup.defending.doubleEffectiveTypes)}
|
||||
**Resistances:**
|
||||
${this.parseResistedTypes(typeMatchup.defending.resistedTypes, typeMatchup.defending.doubleResistedTypes)}${immune}
|
||||
`);
|
||||
editMessage.edit({ content: null, embeds: [embed] });
|
||||
});
|
||||
}
|
||||
|
||||
parseEffectiveTypes (effective, doubleEffective) {
|
||||
return doubleEffective
|
||||
.map(type => `\`${type.toProperCase()} (x4)\``)
|
||||
.concat(effective.map(type => `\`${type.toProperCase()} (x2)\``))
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
parseResistedTypes (resisted, doubleResisted) {
|
||||
return doubleResisted
|
||||
.map(type => `\`${type.toProperCase()} (x0.25)\``)
|
||||
.concat(resisted.map(type => `\`${type.toProperCase()} (x0.5)\``))
|
||||
.join(' ');
|
||||
}
|
||||
};
|
|
@ -1,82 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'Gets information on a held item.',
|
||||
arguments: '<item>',
|
||||
details: '',
|
||||
examples: 'item life orb\nitem griseous orb'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
if (!args[0]) return message.channel.send(
|
||||
`${client.config.emojis.userError} You didn't give me an item to look up!`
|
||||
);
|
||||
|
||||
const editMessage = await message.channel.send(`${client.config.emojis.loading} Please wait...`);
|
||||
|
||||
const query = args.join(' ').toLowerCase();
|
||||
|
||||
fetch('https://graphqlpokemon.favware.tech/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': client.config.userAgent
|
||||
},
|
||||
body: JSON.stringify({ query: `
|
||||
{
|
||||
getItemDetailsByFuzzy(item: "${query}") {
|
||||
name
|
||||
desc
|
||||
shortDesc
|
||||
sprite
|
||||
generationIntroduced
|
||||
bulbapediaPage
|
||||
serebiiPage
|
||||
smogonPage
|
||||
}
|
||||
}
|
||||
`})
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
if (json.errors) {
|
||||
json.errors.forEach(error => {
|
||||
if (error.message.startsWith('Failed to get data for item')) {
|
||||
message.channel.send(
|
||||
`${client.config.emojis.userError} I couldn't find any items with names similar to ${query}. Check your spelling, maybe?`
|
||||
);
|
||||
} else {
|
||||
client.logger.error('POKEMON_API_ERROR', error.message);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const item = json.data.getItemDetailsByFuzzy;
|
||||
|
||||
const embed = new client.MessageEmbed()
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.setTitle(item.name)
|
||||
.setThumbnail(item.sprite)
|
||||
.addField('External Resources:', `[Bulbapedia](${item.bulbapediaPage}) • [Serebii](${item.serebiiPage}) • [Smogon](${item.smogonPage})`);
|
||||
if (item.desc) {
|
||||
embed.setDescription(`${item.desc} Added in Generation ${item.generationIntroduced}.`);
|
||||
} else {
|
||||
embed.setDescription(`${item.shortDesc} Added in Generation ${item.generationIntroduced}.`);
|
||||
}
|
||||
editMessage.edit({ content: null, embeds: [embed] });
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,119 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
const { colours } = require('../../assets/pokemon.json');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 2000,
|
||||
this.help = {
|
||||
description: 'Gets information on a pokemon move.',
|
||||
arguments: '<move>',
|
||||
details: '',
|
||||
examples: `${this.name} roar of time\n${this.name} shadow ball`
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
if (!args[0]) return message.channel.send(
|
||||
`${client.config.emojis.userError} You didn't give me a pokemon move to look up!`
|
||||
);
|
||||
|
||||
const editMessage = await message.channel.send(`${client.config.emojis.loading} Please wait...`);
|
||||
|
||||
const query = args.join(' ').toLowerCase();
|
||||
|
||||
fetch('https://graphqlpokemon.favware.tech/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': client.config.userAgent
|
||||
},
|
||||
body: JSON.stringify({ query: `
|
||||
{
|
||||
getMoveDetailsByFuzzy(move: "${query}") {
|
||||
name
|
||||
desc
|
||||
shortDesc
|
||||
type
|
||||
basePower
|
||||
zMovePower
|
||||
maxMovePower
|
||||
pp
|
||||
category
|
||||
accuracy
|
||||
priority
|
||||
target
|
||||
isZ
|
||||
isGMax
|
||||
contestType
|
||||
bulbapediaPage
|
||||
serebiiPage
|
||||
smogonPage
|
||||
isFieldMove
|
||||
}
|
||||
}
|
||||
`})
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
if (json.errors) {
|
||||
json.errors.forEach(error => {
|
||||
if (error.message.startsWith('Failed to get data for move')) {
|
||||
message.channel.send(
|
||||
`${client.config.emojis.userError} I couldn't find any moves with names similar to ${query}. Check your spelling, maybe?`
|
||||
);
|
||||
} else {
|
||||
client.logger.error('POKEMON_API_ERROR', error.message);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const move = json.data.getMoveDetailsByFuzzy;
|
||||
|
||||
let suffix = '';
|
||||
|
||||
if (move.isZ) {
|
||||
suffix = ' (Z-Move)';
|
||||
} else if (!move.maxMovePower && move.basePower > 0) {
|
||||
suffix = ' (Max Move)';
|
||||
} else if (move.isGMax) {
|
||||
suffix = ' (G-Max Move)';
|
||||
}
|
||||
|
||||
let fieldEffects = '';
|
||||
if (move.isFieldMove) fieldEffects = ' Outside of battle, ' + move.isFieldMove;
|
||||
|
||||
const embed = new client.MessageEmbed()
|
||||
.setColor(colours[move.type])
|
||||
.setTitle(move.name.toProperCase() + suffix);
|
||||
if (move.desc) {
|
||||
embed.setDescription(move.desc + fieldEffects);
|
||||
} else {
|
||||
embed.setDescription(move.shortDesc + fieldEffects);
|
||||
}
|
||||
|
||||
embed.addField('Type:', move.type, true);
|
||||
embed.addField('Category:', move.category, true);
|
||||
embed.addField('Target:', move.target, true);
|
||||
if (!move.isZ || move.maxMovePower) embed.addField('Base Power:', move.basePower.toString(), true);
|
||||
if (!move.isZ || move.maxMovePower) embed.addField('Z Power:', move.zMovePower.toString(), true);
|
||||
if (move.maxMovePower) embed.addField('Max Power:', move.maxMovePower.toString(), true);
|
||||
if (!move.isZ) embed.addField('Base PP:', move.pp.toString(), true);
|
||||
embed.addField('Accuracy:', move.accuracy.toString(), true);
|
||||
embed.addField('Priority:', move.priority.toString(), true);
|
||||
if (move.isZ) embed.addField('Z-Crystal:', move.isZ, true);
|
||||
if (move.isGMax) embed.addField('G-Max Pokemon:', move.isGMax, true);
|
||||
if (move.contestType !== null) embed.addField('Contest Type', move.contestType, true);
|
||||
embed.addField('External Resources:', `[Bulbapedia](${move.bulbapediaPage}) • [Serebii](${move.serebiiPage}) • [Smogon](${move.smogonPage})`);
|
||||
editMessage.edit({ content: null, embeds: [embed] });
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,180 +0,0 @@
|
|||
const { colours } = require('../../assets/pokemon.json');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = ['pokedex', 'dex'],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 5000,
|
||||
this.help = {
|
||||
description: 'Get useful data on any pokemon you ask me to!',
|
||||
arguments: '<pokemon>',
|
||||
details: '',
|
||||
examples: '`pokemon mudkip`\n`pokemon alolan ninetales`'
|
||||
};
|
||||
}
|
||||
|
||||
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
if (!args[0]) return message.channel.send(
|
||||
`${client.config.emojis.userError} You didn't give me a pokemon to look up!`
|
||||
);
|
||||
|
||||
const editMessage = await message.channel.send(`${client.config.emojis.loading} Please wait...`);
|
||||
|
||||
const query = args.join(' ').toLowerCase();
|
||||
|
||||
fetch('https://graphqlpokemon.favware.tech/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': client.config.userAgent
|
||||
},
|
||||
body: JSON.stringify({ query: `
|
||||
{
|
||||
getPokemonDetailsByFuzzy(pokemon: "${query}" reverse: true) {
|
||||
num
|
||||
species
|
||||
types
|
||||
abilities { first second hidden special }
|
||||
baseStats { hp attack defense specialattack specialdefense speed }
|
||||
eggGroups
|
||||
evolutionLevel
|
||||
evolutions { species evolutionLevel evolutions { species evolutionLevel } }
|
||||
preevolutions { species evolutionLevel preevolutions { species evolutionLevel } }
|
||||
gender { male female }
|
||||
height
|
||||
weight
|
||||
otherFormes
|
||||
cosmeticFormes
|
||||
baseStatsTotal
|
||||
flavorTexts { game flavor }
|
||||
sprite
|
||||
shinySprite
|
||||
smogonTier
|
||||
bulbapediaPage
|
||||
serebiiPage
|
||||
smogonPage
|
||||
}
|
||||
}
|
||||
`})
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((json) => {
|
||||
if (json.errors) {
|
||||
json.errors.forEach(error => {
|
||||
if (error.message.startsWith('No Pokémon found')) {
|
||||
message.channel.send(
|
||||
`${client.config.emojis.userError} I couldn't find any Pokemon with names similar to ${query}. Check your spelling, maybe?`
|
||||
);
|
||||
} else {
|
||||
client.logger.error('POKEMON_API_ERROR', error.message);
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const pokemon = json.data.getPokemonDetailsByFuzzy;
|
||||
const evoChain = this.parseEvoChain(pokemon);
|
||||
const genderRatio = this.parseGenderRatio(pokemon.gender);
|
||||
const abilities = this.parseAbilities(pokemon.abilities);
|
||||
let sprite = pokemon.sprite;
|
||||
if (Math.floor((Math.random() * 100) + 1) === 69) sprite = pokemon.shinySprite;
|
||||
let formes;
|
||||
if (pokemon.otherFormes) {
|
||||
formes = pokemon.otherFormes.join(', ');
|
||||
if (pokemon.cosmeticFormes) {
|
||||
formes = formes.split().concat(pokemon.cosmeticFormes);
|
||||
}
|
||||
}
|
||||
const embed = new client.MessageEmbed()
|
||||
.setColor(colours[pokemon.types[0]])
|
||||
.setTitle(`${pokemon.species.toProperCase()} (No. ${pokemon.num})`)
|
||||
.setDescription(pokemon.flavorTexts[0].flavor)
|
||||
.setThumbnail(sprite)
|
||||
.addField('Types:', pokemon.types.join(', '), true)
|
||||
.addField('Abilities:', abilities.join(', '), true)
|
||||
.addField('Gender Ratio:', genderRatio, true)
|
||||
.addField('Base Stats:', `HP: ${pokemon.baseStats.hp} Atk: ${pokemon.baseStats.attack} Def: ${pokemon.baseStats.defense} SpA: ${pokemon.baseStats.specialattack} SpD: ${pokemon.baseStats.specialdefense} Spe: ${pokemon.baseStats.speed} BST: ${pokemon.baseStatsTotal}`);
|
||||
if (evoChain) embed.addField('Evolution Chain:', evoChain);
|
||||
if (formes) embed.addField('Other Formes:', formes);
|
||||
embed.addField('Height:', `${pokemon.height}m`, true);
|
||||
embed.addField('Weight:', `${pokemon.weight}kg`, true);
|
||||
embed.addField('Egg Groups:', pokemon.eggGroups.join(', '), true);
|
||||
embed.addField('Smogon Tier:', pokemon.smogonTier, true);
|
||||
embed.addField('External Resources:', `[Bulbapedia](${pokemon.bulbapediaPage}) • [Serebii](${pokemon.serebiiPage}) • [Smogon](${pokemon.smogonPage})`);
|
||||
editMessage.edit({ content: null, embeds: [embed] });
|
||||
});
|
||||
}
|
||||
|
||||
constructEvoLink (species, level, evoChain, isEvo = true) {
|
||||
if (isEvo) {
|
||||
return `${evoChain} → \`${species.toProperCase()}\` ${level ? `(${level})` : ''}`;
|
||||
}
|
||||
return `\`${species.toProperCase()}\` ${level ? `(${level})` : ''} → ${evoChain}`;
|
||||
}
|
||||
|
||||
parseEvoChain (pokeDetails) {
|
||||
// Set evochain if there are no evolutions
|
||||
let evoChain = `**${pokeDetails.species.toProperCase()} ${pokeDetails.evolutionLevel ? `(${pokeDetails.evolutionLevel})` : ''}**`;
|
||||
if (!pokeDetails.evolutions && !pokeDetails.preevolutions) {
|
||||
evoChain = null;
|
||||
}
|
||||
|
||||
// Parse pre-evolutions and add to evochain
|
||||
if (pokeDetails.preevolutions) {
|
||||
const { evolutionLevel } = pokeDetails.preevolutions[0];
|
||||
evoChain = this.constructEvoLink(pokeDetails.preevolutions[0].species, evolutionLevel, evoChain, false);
|
||||
|
||||
// If the direct pre-evolution has another pre-evolution (charizard -> charmeleon -> charmander)
|
||||
if (pokeDetails.preevolutions[0].preevolutions) {
|
||||
evoChain = this.constructEvoLink(pokeDetails.preevolutions[0].preevolutions[0].species, null, evoChain, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse evolution chain and add to evochain
|
||||
if (pokeDetails.evolutions) {
|
||||
evoChain = this.constructEvoLink(pokeDetails.evolutions[0].species, pokeDetails.evolutions[0].evolutionLevel, evoChain);
|
||||
|
||||
// In case there are multiple evolutionary paths
|
||||
const otherFormeEvos = pokeDetails.evolutions.slice(1);
|
||||
if (otherFormeEvos) {
|
||||
evoChain = `${evoChain}, ${otherFormeEvos.map((oevo) => `\`${oevo.species}\` (${oevo.evolutionLevel})`).join(', ')}`;
|
||||
}
|
||||
|
||||
// If the direct evolution has another evolution (charmander -> charmeleon -> charizard)
|
||||
if (pokeDetails.evolutions[0].evolutions) {
|
||||
evoChain = this.constructEvoLink(
|
||||
pokeDetails.evolutions[0].evolutions[0].species,
|
||||
pokeDetails.evolutions[0].evolutions[0].evolutionLevel,
|
||||
evoChain
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return evoChain;
|
||||
}
|
||||
|
||||
parseGenderRatio (genderRatio) {
|
||||
if (genderRatio.male === '0%' && genderRatio.female === '0%') {
|
||||
return 'Genderless';
|
||||
}
|
||||
|
||||
return `${genderRatio.male} ♂ | ${genderRatio.female} ♀`;
|
||||
}
|
||||
|
||||
parseAbilities (abilitiesData) {
|
||||
const abilities = [];
|
||||
for (const [type, ability] of Object.entries(abilitiesData)) {
|
||||
if (!ability) continue;
|
||||
abilities.push(type === 'hidden' ? `*${ability}*` : ability);
|
||||
}
|
||||
|
||||
return abilities;
|
||||
}
|
||||
};
|
|
@ -1,74 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
const prettifyMiliseconds = require('pretty-ms');
|
||||
const { createPaginationEmbed } = require('eris-pagination');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 30000,
|
||||
this.help = {
|
||||
description: 'Get current map, weapons and gear for salmon run.',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
message.channel.sendTyping();
|
||||
fetch('https://splatoon2.ink/data/coop-schedules.json', { headers: { 'User-Agent': client.config.userAgent }})
|
||||
.then(res => res.json())
|
||||
.then(json => {
|
||||
fetch('https://splatoon2.ink/data/timeline.json', { headers: { 'User-Agent': client.config.userAgent }})
|
||||
.then(timelineRes => timelineRes.json())
|
||||
.then(timelineJson => {
|
||||
|
||||
const embeds = [];
|
||||
|
||||
if ((json.details[0].start_time * 1000) > Date.now() === true) {
|
||||
embeds.push(
|
||||
new client.MessageEmbed()
|
||||
.setTitle('Upcoming Salmon Run')
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.setImage('https://splatoon2.ink/assets/splatnet/'+json.details[0].stage.image)
|
||||
.addField('Map', json.details[0].stage.name, true)
|
||||
.setFooter(`Starting in ${prettifyMiliseconds(json.details[0].start_time * 1000 - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`)
|
||||
);
|
||||
} else {
|
||||
embeds.push(
|
||||
new client.MessageEmbed()
|
||||
.setTitle('Current Salmon Run')
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.setThumbnail('https://splatoon2.ink/assets/splatnet'+timelineJson.coop.reward_gear.gear.image)
|
||||
.setImage('https://splatoon2.ink/assets/splatnet/'+json.details[0].stage.image)
|
||||
.addField('Map', json.details[0].stage.name, true)
|
||||
.addField('Reward Gear', timelineJson.coop.reward_gear.gear.name, true)
|
||||
.addField('Weapons', json.details[0].weapons[0].weapon.name+', '+json.details[0].weapons[1].weapon.name+', '+json.details[0].weapons[2].weapon.name+', '+json.details[0].weapons[3].weapon.name)
|
||||
.setFooter(`Ending in ${prettifyMiliseconds((json.details[0].end_time * 1000) - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`)
|
||||
);
|
||||
}
|
||||
|
||||
embeds.push(
|
||||
new client.MessageEmbed()
|
||||
.setTitle('Upcoming Salmon Run')
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.setImage('https://splatoon2.ink/assets/splatnet/'+json.details[1].stage.image)
|
||||
.addField('Map', json.details[1].stage.name, true)
|
||||
.addField('Weapons', json.details[1].weapons[1].weapon.name+', '+json.details[1].weapons[1].weapon.name+', '+json.details[1].weapons[2].weapon.name+', '+json.details[1].weapons[3].weapon.name)
|
||||
.setFooter(`Starting in ${prettifyMiliseconds(json.details[1].start_time * 1000 - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`)
|
||||
);
|
||||
|
||||
createPaginationEmbed(message, embeds);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
message.channel.send(`${client.config.emojis.botError} An error has occurred: ${err}`);
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,50 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
const prettifyMiliseconds = require('pretty-ms');
|
||||
const { createPaginationEmbed } = require('eris-pagination');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = [],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 30000,
|
||||
this.help = {
|
||||
description: 'See what is currently on offer in the splatnet shop',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
message.channel.sendTyping();
|
||||
fetch('https://splatoon2.ink//data/merchandises.json', { headers: { 'User-Agent': client.config.userAgent }})
|
||||
.then(res => res.json())
|
||||
.then(json => {
|
||||
const embeds = [];
|
||||
|
||||
for ( let i = 0; i < json.merchandises.length; i++ ) {
|
||||
const embed = new client.MessageEmbed()
|
||||
.setTitle(json.merchandises[i].gear.name)
|
||||
.setThumbnail('https://splatoon2.ink/assets/splatnet' + json.merchandises[i].gear.image)
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.addField('Price', (json.merchandises[i].price).toString(), true)
|
||||
.addField('Brand', json.merchandises[i].gear.brand.name, true)
|
||||
.addField('Ability Slots', (json.merchandises[i].gear.rarity + 1).toString(), true)
|
||||
.addField('Main Ability', json.merchandises[i].skill.name, true)
|
||||
.addField('Common Ability', json.merchandises[i].gear.brand.frequent_skill.name, true)
|
||||
.setFooter('Out of stock in ' + prettifyMiliseconds(json.merchandises[i].end_time * 1000 - Date.now()) + ' | Data provided by splatoon2.ink');
|
||||
embeds.push(embed);
|
||||
}
|
||||
|
||||
createPaginationEmbed(message, embeds);
|
||||
})
|
||||
.catch(err => {
|
||||
message.channel.send(`${client.config.emojis.botError} An error has occurred: ${err}`);
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,56 +0,0 @@
|
|||
const fetch = require('node-fetch');
|
||||
const prettifyMiliseconds = require('pretty-ms');
|
||||
const { createPaginationEmbed } = require('eris-pagination');
|
||||
|
||||
module.exports = class {
|
||||
constructor (name, category) {
|
||||
this.name = name,
|
||||
this.category = category,
|
||||
this.enabled = true,
|
||||
this.devOnly = false,
|
||||
this.aliases = ['splatoonmodes'],
|
||||
this.userPerms = [],
|
||||
this.botPerms = [],
|
||||
this.cooldown = 30000,
|
||||
this.help = {
|
||||
description: 'Get current and upcoming maps and modes for regular, ranked and league battles.',
|
||||
arguments: '',
|
||||
details: '',
|
||||
examples: ''
|
||||
};
|
||||
}
|
||||
|
||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||
message.channel.sendTyping();
|
||||
fetch('https://splatoon2.ink/data/schedules.json', { headers: { 'User-Agent': client.config.userAgent }})
|
||||
.then(res => res.json())
|
||||
.then(json => {
|
||||
|
||||
const embeds = [
|
||||
new client.MessageEmbed()
|
||||
.setTitle('Current Splatoon 2 Maps')
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.addField('<:turf_war:814651383911153692> Turf War', `${json.regular[0].stage_a.name}\n${json.regular[0].stage_b.name}`, true)
|
||||
.addField(`<:ranked:814651402479468544> Ranked: ${json.gachi[0].rule.name}`, `${json.gachi[0].stage_a.name}\n${json.gachi[0].stage_b.name}`, true)
|
||||
.addField(`<:league:814651415409590363> League: ${json.league[0].rule.name}`, `${json.league[0].stage_a.name}\n${json.league[0].stage_b.name}`, true)
|
||||
.setFooter(`Maps changing in ${prettifyMiliseconds(json.league[0].end_time * 1000 - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`)
|
||||
];
|
||||
|
||||
for ( let i = 1; i < json.regular.length; i++ ) {
|
||||
const embed = new client.MessageEmbed()
|
||||
.setTitle('Upcoming Splatoon 2 Maps')
|
||||
.setColor(client.functions.embedColor(message.guild))
|
||||
.addField('<:turf_war:814651383911153692> Turf War', `${json.regular[i].stage_a.name}\n${json.regular[i].stage_b.name}`, true)
|
||||
.addField(`<:ranked:814651402479468544> Ranked: ${json.gachi[i].rule.name}`, `${json.gachi[i].stage_a.name}\n${json.gachi[i].stage_b.name}`, true)
|
||||
.addField(`<:league:814651415409590363> League: ${json.league[i].rule.name}`, `${json.league[i].stage_a.name}\n${json.league[i].stage_b.name}`, true)
|
||||
.setFooter(`Available in ${prettifyMiliseconds(json.league[i].start_time * 1000 - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`);
|
||||
embeds.push(embed);
|
||||
}
|
||||
|
||||
createPaginationEmbed(message, embeds);
|
||||
})
|
||||
.catch(err => {
|
||||
message.channel.send(`${client.config.emojis.botError} An error has occurred: ${err}`);
|
||||
});
|
||||
}
|
||||
};
|
|
@ -24,7 +24,7 @@ module.exports = class {
|
|||
.setTitle(guild.name)
|
||||
.setThumbnail(guild.iconURL)
|
||||
.addField('ID', guild.id, true)
|
||||
.addField('Owner', `<@${guild.ownerID}>`, true)
|
||||
.addField('Owner', `<@${guild.ownerId}>`, true)
|
||||
.addField('Region', guild.region.toProperCase(), true)
|
||||
.addField('Boosts', `${guild.premiumSubscriptionCount} (Level ${guild.premiumTier})`, true)
|
||||
.addField('Member Count (Approximate)', `${guild.memberCount} (${guild.memberCount - guild.members.filter(member => member.user.bot).length} humans, ${guild.members.filter(member => member.user.bot).length} bots)`, true)
|
||||
|
|
|
@ -47,7 +47,7 @@ module.exports = class {
|
|||
const badges = [];
|
||||
|
||||
if (client.config.ownerIDs.includes(member.id)) badges.push('<:Woomy_Developer:816822318289518622> ');
|
||||
if (member.id === member.guild.ownerID) badges.push('<:owner:685703193694306331>');
|
||||
if (member.id === member.guild.ownerId) badges.push('<:owner:685703193694306331>');
|
||||
if (member.bot) badges.push('<:bot:686489601678114859>');
|
||||
|
||||
const roles = [];
|
||||
|
|
|
@ -13,52 +13,45 @@ class EventHandler {
|
|||
break;
|
||||
}
|
||||
|
||||
// param_1 - error message
|
||||
case 'error': {
|
||||
const errorModules = this.client.eventModules.filter(module => module.wsEvent === 'error');
|
||||
errorModules.forEach(module => module.run(this.client, param_1));
|
||||
errorModules.forEach(module => module.run(this.client, error));
|
||||
break;
|
||||
}
|
||||
|
||||
// param_1 - message object
|
||||
case 'messageCreate': {
|
||||
const mCreateModules = this.client.eventModules.filter(module => module.wsEvent === 'messageCreate');
|
||||
mCreateModules.forEach(module => module.run(this.client, param_1));
|
||||
mCreateModules.forEach(module => module.run(this.client, message));
|
||||
break;
|
||||
}
|
||||
|
||||
// param_1 - guild object
|
||||
case 'guildCreate': {
|
||||
const gCreateModules = this.client.eventModules.filter(module => module.wsEvent === 'guildCreate');
|
||||
gCreateModules.forEach(module => module.run(this.client, param_1));
|
||||
gCreateModules.forEach(module => module.run(this.client, guild));
|
||||
break;
|
||||
}
|
||||
|
||||
// param_1 - guild object
|
||||
case 'guildDelete': {
|
||||
const gDeleteModules = this.client.eventModules.filter(module => module.wsEvent === 'guildDelete');
|
||||
gDeleteModules.forEach(module => module.run(this.client, param_1));
|
||||
gDeleteModules.forEach(module => module.run(this.client, guild));
|
||||
break;
|
||||
}
|
||||
|
||||
// param_1 - guild object | param_2 - member object
|
||||
case 'guildMemberAdd': {
|
||||
const gMemberAddModules = this.client.eventModules.filter(module => module.wsEvent === 'guildMemberAdd');
|
||||
gMemberAddModules.forEach(module => module.run(this.client, param_1, param_2));
|
||||
gMemberAddModules.forEach(module => module.run(this.client, guild, member));
|
||||
break;
|
||||
}
|
||||
|
||||
// param_1 - guild object | param_2 - member object
|
||||
case 'guildMemberRemove': {
|
||||
const gMemberRemoveModules = this.client.eventModules.filter(module => module.wsEvent === 'guildMemberRemove');
|
||||
gMemberRemoveModules.forEach(module => module.run(this.client, param_1, param_2));
|
||||
gMemberRemoveModules.forEach(module => module.run(this.client, guild, member));
|
||||
break;
|
||||
}
|
||||
|
||||
// param_1 - old voice state | param_2 - new voice state
|
||||
case 'voiceStateUpdate': {
|
||||
const vStateUpdateModules = this.client.eventModules.filter(module => module.wsEvent === 'voiceStateUpdate');
|
||||
vStateUpdateModules.forEach(module => module.run(this.client));
|
||||
vStateUpdateModules.forEach(module => module.run(this.client, oVoiceState, nVoiceState));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
class MessageHandler {
|
||||
constructor (client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
async handle (message) {
|
||||
// Ignore messages from bots, and messages in DM's
|
||||
if (message.author.bot) return;
|
||||
if (!message.guild) return;
|
||||
|
||||
// Request all the data we need from the database
|
||||
const data = {};
|
||||
data.user = await this.client.db.getUser(message.author.id);
|
||||
data.guild = await this.client.db.getGuild(message.guild.id);
|
||||
data.member = await this.client.db.getMember(message.guild.id, message.author.id);
|
||||
|
||||
// Ignore users on the guild blocklist
|
||||
if (data.guild.blocklist.includes(message.author.id)) return;
|
||||
|
||||
// If a user pings Woomy, respond to them with the prefixes they can use
|
||||
if (message.content === `<@${this.client.user.id}>` || message.content === `<@!${this.client.user.id}>`) {
|
||||
return message.channel.send(
|
||||
`Hi! The prefix for this server is \`${data.guild.prefix}\`, and your personal prefix is \`${data.user.prefix}\`. You can also ping me ^-^`
|
||||
);
|
||||
}
|
||||
|
||||
// All the prefixes Woomy will respond to
|
||||
const prefixes = [
|
||||
data.user.prefix,
|
||||
data.guild.prefix,
|
||||
`<@${this.client.user.id}> `,
|
||||
`<@!${this.client.user.id}> `
|
||||
];
|
||||
|
||||
let prefix;
|
||||
|
||||
// Check the message content to see if it starts with one of our prefixes
|
||||
for (const thisPrefix of prefixes) {
|
||||
if (message.content.startsWith(thisPrefix)) {
|
||||
prefix = thisPrefix;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore the message if it doesn't start with a valid prefix
|
||||
if (!prefix) return;
|
||||
|
||||
// Save prefix so we can use it later (mostly for help command)
|
||||
if (prefix === `<@${this.client.user.id}> ` || prefix === `<@!${this.client.user.id}> `) {
|
||||
message.prefix = '@Woomy ';
|
||||
} else (message.prefix = prefix);
|
||||
|
||||
// Turn the message content into an array (excluding the prefix)
|
||||
const args = message.content.slice(prefix.length).trim().split(/ +/g);
|
||||
|
||||
// Find the command
|
||||
const commandName = args.shift().toLowerCase();
|
||||
const command = this.client.commands.get(commandName) || this.client.commands.get(this.client.aliases.get(commandName));
|
||||
|
||||
// Return if a command (or its aliases) are not found
|
||||
if (!command) return;
|
||||
|
||||
// Both of these blocks check if the command is disabled/in a disabled category
|
||||
if (data.guild.disabledcommands.includes(command.name)) return message.channel.send(
|
||||
this.client.config.emojis.permError + ' This command has been disabled by a server administrator.'
|
||||
);
|
||||
|
||||
if (data.guild.disabledcategories.includes(command.category)) return message.channel.send(
|
||||
this.client.config.emojis.permError + ' The category this command is apart of has been disabled by a server administrator.'
|
||||
);
|
||||
|
||||
// Both of these blocks check the permissions of the user, and reply with missing perms if any are found
|
||||
const missingUserPerms = this.client.functions.checkPermissions(message.channel, message.author.id, command.userPerms);
|
||||
if (missingUserPerms) return message.channel.send(
|
||||
`${this.client.config.emojis.permError} You can't use this command because you lack these permissions: \`${missingUserPerms.join('`, `')}\``
|
||||
);
|
||||
|
||||
const missingBotPerms = this.client.functions.checkPermissions(message.channel, this.client.user.id, command.botPerms);
|
||||
if (missingBotPerms) return message.channel.send(
|
||||
`${this.client.config.emojis.permError} I can't run this command because I lack these permissions: \`${missingBotPerms.join('`, `')}\``
|
||||
);
|
||||
|
||||
// Return if the command is disabled globally
|
||||
if (command.enabled === false) return message.channel.send(
|
||||
this.client.config.emojis.permError + ' This command has been disabled by my developers.'
|
||||
);
|
||||
|
||||
// Return if the command is restricted to developers (and the user is not a developer)
|
||||
if (command.devOnly === true && this.client.config.ownerIDs.includes(message.author.id) !== true) {
|
||||
return message.channel.send(
|
||||
`${this.client.config.emojis.permError} ${message.author.username} is not in the sudoers file. This incident will be reported.`
|
||||
);
|
||||
}
|
||||
|
||||
// Cooldown
|
||||
if (this.client.cooldowns.get(command.name).has(message.author.id)) {
|
||||
const timestamp = this.client.cooldowns.get(command.name).get(message.author.id);
|
||||
const currentTime = Date.now();
|
||||
const cooldown = command.cooldown / 1000;
|
||||
const timePassed = Math.floor((currentTime - timestamp) / 1000);
|
||||
return message.channel.send(
|
||||
`${this.client.config.emojis.wait} ${message.author.mention}, you need to wait ${cooldown - timePassed} seconds before using this command again.`
|
||||
);
|
||||
} else {
|
||||
this.client.cooldowns.get(command.name).set(message.author.id, new Date());
|
||||
setTimeout(() => {
|
||||
this.client.cooldowns.get(command.name).delete(message.author.id);
|
||||
}, this.client.commands.get(command.name).cooldown);
|
||||
}
|
||||
|
||||
try {
|
||||
command.run(this.client, message, args, data);
|
||||
this.client.logger.command(`Ran ${command.name}`);
|
||||
} catch (error) {
|
||||
this.client.logger.error('COMMAND_EXECUTION_ERROR', `${command.name}: ${error.stack}`);
|
||||
message.channel.send(`${this.client.config.emojis.botError} An error occured when I was trying to run this command. I've sent through the details of the error to my developers.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MessageHandler;
|
19
bot/index.js
19
bot/index.js
|
@ -4,7 +4,7 @@ const Discord = require('discord.js');
|
|||
const CommandLoader = require('./util/commandLoader');
|
||||
const EventLoader = require('./util/eventLoader');
|
||||
const EventHandler = require('./event_modules/eventHandler');
|
||||
const MessageHandler = require('./event_modules/interactionCreate/messageHandler');
|
||||
const MessageHandler = require('./event_modules/messageCreate/messageHandler');
|
||||
const Functions = require('./util/functions');
|
||||
const Database = require('./util/database');
|
||||
const Logger = require('./util/logger');
|
||||
|
@ -41,8 +41,8 @@ class WoomyClient extends Discord.Client {
|
|||
createEventListeners () {
|
||||
this.on('ready', this.runReadyModules);
|
||||
this.on('error', this.runErrorModules);
|
||||
this.on('interactionCreate', this.runInteractionModules);
|
||||
/// this.on('messageCreate', this.runMessageCreateModules);
|
||||
this.on('interactionCreate', this.runInteractionCreateModules);
|
||||
this.on('messageCreate', this.runMessageCreateModules);
|
||||
this.on('guildCreate', this.runGuildCreateModules);
|
||||
this.on('guildDelete', this.runGuildDeleteModules);
|
||||
this.on('guildMemberAdd', this.runGuildMemberAddModules);
|
||||
|
@ -73,6 +73,7 @@ class WoomyClient extends Discord.Client {
|
|||
}
|
||||
|
||||
runMessageCreateModules (message) {
|
||||
this.messageHandler.handle(message);
|
||||
this.mainEventListener('messageCreate', message);
|
||||
}
|
||||
|
||||
|
@ -101,7 +102,7 @@ class WoomyClient extends Discord.Client {
|
|||
const client = new WoomyClient({
|
||||
shards: 'auto',
|
||||
partials: [
|
||||
Discord.Partials.Reaction,
|
||||
Discord.Partials.Reaction
|
||||
],
|
||||
intents: [
|
||||
Discord.GatewayIntentBits.Guilds,
|
||||
|
@ -110,8 +111,14 @@ const client = new WoomyClient({
|
|||
Discord.GatewayIntentBits.GuildVoiceStates,
|
||||
Discord.GatewayIntentBits.GuildMessages,
|
||||
Discord.GatewayIntentBits.MessageContent,
|
||||
Discord.GatewayIntentBits.GuildMessageReactions,
|
||||
]
|
||||
Discord.GatewayIntentBits.GuildMessageReactions
|
||||
],
|
||||
allowedMentions: {
|
||||
parse: [
|
||||
'users',
|
||||
'roles'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// Extensions of native javascript types, *not good practice* but they're useful
|
||||
|
|
Loading…
Reference in New Issue