This commit is contained in:
Emily 2020-10-20 12:27:34 +11:00
parent 4ac2d2e927
commit 00bbebcf4a
32 changed files with 0 additions and 3610 deletions

View file

@ -1,92 +0,0 @@
const Command = require('../../base/Command.js');
class Blacklist extends Command {
constructor (client) {
super(client, {
description: 'Add and remove users from the blacklist, preventing them from using commands in this server.',
usage: '`blacklist [add <user> | remove <user>]`',
examples: '`blacklist`\n`blacklist add @annoyinguser123`\n`blacklist remove @cooluser456`',
userPerms: ['ADMINISTRATOR'],
guildOnly: true
});
}
async run (message, [action, ...user], data) { // eslint-disable-line no-unused-vars
if (!action) {
return;
} else {
if (!user) return message.channel.send(
'You didn\'t specify a user!'
);
let member = message.mentions.users.first();
if (!member && message.guild) {
member = this.client.functions.searchForMembers(message.guild, user);
if (member.length > 1) {
return message.channel.send(
'Found multiple users, please be more specific or @mention the user instead.'
);
}
if (member.length < 1) {
return message.channel.send(
'Specified user couldn\'t be found, check for typing errors.'
);
}
}
member = member[0];
const array = data.guild.blacklist;
action = action.toLowerCase();
if (action === 'add') {
if (member.user.id === message.guild.owner.id) return message.channel.send(
'You can\'t add the owner to the blocklist!'
);
if (member.roles.highest.position >= message.guild.member(message.author).roles.highest.position && message.author.id !== message.guild.ownerID) {
return message.channel.send(
'You can\'t add people higher ranked than yourself to the blocklist!'
);
}
if (array.includes(member.user.id)) return message.channel.send(
'This user has already been blacklisted.'
);
array.push(member.user.id);
await this.client.db.updateGuild(message.guild.id, 'blacklist', array);
return message.channel.send(
`Added \`${member.user.tag}\` to the blocklist.`
);
}
if (action === 'remove') {
if (member.roles.highest.position >= message.guild.member(message.author).roles.highest.position && message.author.id !== message.guild.ownerID) {
return message.channel.send(
'You can\'t remove people higher ranked than yourself from the blocklist!'
);
}
if (!array.includes(member.user.id)) return message.channel.send(
'This user isn\'t blacklisted.'
);
array.remove(member.user.id);
await this.client.db.updateGuild(message.guild.id, 'blacklist', array);
return message.channel.send(
`Removed \`${member.user.tag}\` from the blocklist.`
);
}
}
}
}
module.exports = Blacklist;

View file

@ -1,90 +0,0 @@
const Command = require('../../base/Command.js');
class Disable extends Command {
constructor (client) {
super(client, {
description: 'Disables a command/category so they can\'t be used in this server.',
usage: '`disable command [command]` - Disables the specified command.\n`disable category [category]` - Disables the specified category.',
examples: '`disable command cuddle`\n`disable category music`',
userPerms: ['ADMINISTRATOR'],
guildOnly: true
});
}
async run (message, args, data) {
const essentialCategories = [
'Configuration',
'Developer'
];
const essentialCommands = [
'help'
];
if (!args[0]) {
return;
} else {
if (!args[1]) return message.channel.send(
'You didn\'t specify a command/category to disable!'
);
if (args[0] === 'command') {
const array = data.guild.disabledcommands;
const name = args[1].toLowerCase();
let command;
if (this.client.commands.has(name)) {
command = this.client.commands.get(name);
} else if (this.client.aliases.has(name)) {
command = this.client.commands.get(this.client.aliases.get(name));
}
if (!command) return message.channel.send(
`\`${args[0]}\` does not exist as a command or an alias.`
);
if (essentialCategories.includes(command.help.category) || essentialCommands.includes(command.help.name)) {
return message.channel.send('This command is essential, and cannot be disabled.');
}
if (array.includes(command.help.name)) return message.channel.send(
'This command has already been disabled. Use `enable` to re-enable it.'
);
array.push(command.help.name);
await this.client.db.updateGuild(message.guild.id, 'disabledcommands', array);
return message.channel.send(`Disabled command \`${name}\``);
}
if (args[0] === 'category') {
const array = data.guild.disabledcategories;
const name = args[1].toProperCase();
if (!this.client.categories.includes(name)) return message.channel.send(
'I couldn\'t find this category. Are you sure you spelt it correctly?'
);
if (essentialCategories.includes(name)) return message.channel.send(
'This category is essential, and cannot be disabled.'
);
if (array.includes(name)) return message.channel.send(
'This command has already been disabled. Use `enable` to re-enable it.'
);
array.push(name);
await this.client.db.updateGuild(message.guild.id, 'disabledcategories', array);
return message.channel.send(`Disabled category \`${name}\``);
}
}
return message.channel.send('didn\'t specify whether to disable a command or category');
}
}
module.exports = Disable;

View file

@ -1,73 +0,0 @@
const Command = require('../../base/Command.js');
class Enable extends Command {
constructor (client) {
super(client, {
description: 'Re-enables a previously disabled command/category.',
usage: '`enable command [command]` - Enables the specified command.\n`enable category [category]` - Enables the specified category.',
examples: '`enable command cuddle`\n`enable category music`',
userPerms: ['ADMINISTRATOR'],
guildOnly: true
});
}
async run (message, args, data) {
if (!args[0]) {
return;
} else {
if (!args[1]) return message.channel.send(
'You didn\'t specify a command/category to enable!'
);
if (args[0] === 'command') {
const array = data.guild.disabledcommands;
const name = args[1].toLowerCase();
let command;
if (this.client.commands.has(name)) {
command = this.client.commands.get(name);
} else if (this.client.aliases.has(name)) {
command = this.client.commands.get(this.client.aliases.get(name));
}
if (!command) return message.channel.send(
`\`${args[0]}\` does not exist as a command or an alias.`
);
if (!array.includes(command.help.name)) return message.channel.send(
'This command isn\'t disabled.'
);
array.remove(command.help.name);
await this.client.db.updateGuild(message.guild.id, 'disabledcommands', array);
return message.channel.send(`Enabled command \`${name}\``);
}
if (args[0] === 'category') {
const array = data.guild.disabledcategories;
const name = args[1].toProperCase();
if (!this.client.categories.includes(name)) return message.channel.send(
'I couldn\'t find this category. Are you sure you spelt it correctly?'
);
if (!array.includes(name)) return message.channel.send(
'This command isn\'t disabled.'
);
array.remove(name);
await this.client.db.updateGuild(message.guild.id, 'disabledcategories', array);
return message.channel.send(`Enabled category \`${name}\``);
}
}
return message.channel.send('didn\'t specify whether to enable a command or category');
}
}
module.exports = Enable;

View file

@ -1,26 +0,0 @@
const { MessageEmbed } = require('discord.js');
const Command = require('../../base/Command.js');
class Settings extends Command {
constructor (client) {
super(client, {
description: 'View all of your server\'s settings.',
usage: 'settings',
guildOnly: true,
aliases: ['config']
});
}
async run (message, args) { // eslint-disable-line no-unused-vars
const settings = await this.client.db.getGuild(message.guild.id);
const embed = new MessageEmbed()
.setAuthor('Settings Panel', message.guild.iconURL({dynamic: true}))
.setDescription('All the settings for this server are listed below. To set a setting, use `set [setting] [what you want to set it to]')
.addFields(
{ name: '**Prefix**', value: settings.prefix }
);
}
}
module.exports = Settings;

View file

@ -1,25 +0,0 @@
const Command = require('../../base/Command.js');
class Userprefix extends Command {
constructor (client) {
super(client, {
description: 'Change the prefix you use for Woomy. This will affect servers and commands in DM\'s.',
usage: '`userprefix` <new prefix>',
examples: '`userprefix !!` - Sets your personal prefix to !!'
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
if (!args[0]) {
return message.channel.send(
`Your prefix for Woomy is currently: \`${data.user.prefix}\``
);
}
await this.client.db.updateUser(message.author.id, 'prefix', args[0]);
message.channel.send(`Your personal prefix has been set to: \`${args[0]}\``);
}
}
module.exports = Userprefix;

View file

@ -1,17 +0,0 @@
const Command = require('../../base/Command.js');
class Help extends Command {
constructor (client) {
super(client, {
description: 'Lists what commands Woomy has, what they do, and how to use them.',
usage: '`help` - Lists all commands.\n`help <command>` - Shows detailed information on a specific command.',
aliases: ['cmds'],
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
}
}
module.exports = Help;

View file

@ -1,24 +0,0 @@
const Command = require('../../base/Command.js');
class Ping extends Command {
constructor (client) {
super(client, {
description: 'Latency and API response times.',
usage: 'ping',
aliases: ['pong']
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
try {
const msg = await message.channel.send('Pinging...');
msg.edit(
`Pong! \`${msg.createdTimestamp - message.createdTimestamp}ms\` (💗 \`${Math.round(this.client.ws.ping)}ms\`)`
);
} catch (err) {
this.client.logger.err(err);
}
}
}
module.exports = Ping;

View file

@ -1,37 +0,0 @@
const Command = require('../../base/Command.js');
const Discord = require('discord.js');
class Eval extends Command {
constructor (client) {
super(client, {
description: 'Evaluates arbitrary Javascript.',
usage: 'eval <expression>',
aliases: ['ev'],
permLevel: 'Bot Owner',
devOnly: true
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
const code = args.join(' ');
try {
const evaled = eval(code);
const clean = await this.client.functions.clean(evaled);
const MAX_CHARS = 3 + 2 + clean.length + 3;
if (MAX_CHARS > 2000) {
message.channel.send({ files: [new Discord.MessageAttachment(Buffer.from(clean), 'output.txt')] });
}
message.channel.send(`\`\`\`js\n${clean}\n\`\`\``);
} catch (err) {
const e = await this.client.functions.clean(err);
const MAX_CHARS = 1 + 5 + 1 + 3 + e.length + 3;
if (MAX_CHARS > 2000) {
return message.channel.send({ files: [new Discord.MessageAttachment(Buffer.from(e), 'error.txt')] });
}
message.channel.send(`\`ERROR\` \`\`\`xl\n${e}\n\`\`\``);
}
}
}
module.exports = Eval;

View file

@ -1,38 +0,0 @@
const Command = require('../../base/Command.js');
class Reload extends Command {
constructor (client) {
super(client, {
description: 'Latency and API response times.',
usage: '`reload [command]` - Reloads the specified command.',
examples: '`reload ping`',
devOnly: true
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
if (!args[0]) return message.channel.send('You didnt tell me what command to reload!');
let command;
if (this.client.commands.has(args[0])) {
command = this.client.commands.get(args[0]);
} else if (this.client.aliases.has(args[0])) {
command = this.client.commands.get(this.client.aliases.get(args[0]));
}
if (!command) return message.channel.send(
`\`${args[0]}\` does not exist as a command or an alias.`
);
let res = await this.client.commandHandler.unload(command.help.name, command.help.category);
if (res) return message.channel.send('Error unloading: '+ res);
res = await this.client.commandHandler.load(command.help.name, command.help.category);
if (res) return message.channel.send('Error loading: ' + res);
return message.channel.send(`Reloaded \`${args[0]}\``);
}
}
module.exports = Reload;

View file

@ -1,17 +0,0 @@
const Command = require('../../base/Command.js');
class Lastmessage extends Command {
constructor (client) {
super(client, {
description: 'Grab last message sent to a channel.',
usage: 'lastmessage',
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
const lastMsg = await this.client.functions.getLastMessage(message.channel);
message.channel.send(lastMsg);
}
}
module.exports = Lastmessage;

View file

@ -1,36 +0,0 @@
const Command = require('../../base/Command.js');
class Msearch extends Command {
constructor (client) {
super(client, {
description: 'Lists all members found that match the input',
usage: '`msearch` [query] - Finds users in this server that match the query.`',
aliases: ['membersearch']
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
if (!args[0]) return message.channel.send('No username provided.');
let mlist = '';
let count = 0;
this.client.functions.searchForMembers(message.guild, args[0]).forEach((member) => {
if (member) {
mlist += `\`${member.user.tag}\``;
count = count + 1;
}
mlist += '**, **';
});
mlist = mlist.substring(0, mlist.length - 6);
const mlist1 = `Found ${count} users:\n` + mlist;
if (!mlist1) return message.channel.send('No users found!');
message.channel.send(mlist1);
}
}
module.exports = Msearch;

View file

@ -1,32 +0,0 @@
const Command = require('../../base/Command.js');
class Retrieve extends Command {
constructor (client) {
super(client, {
description: 'Retrieves a key\'s value from the Postgres DB.',
usage: 'retrieve [setting]',
guildOnly: true
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
if (!args[0]) return message.channel.send('You didn\'t specify what database to access!');
if (args[0].toLowerCase() !== 'guild' && args[0].toLowerCase() !== 'member' && args[0].toLowerCase() !== 'user') {
return message.channel.send('Invalid database. Valid databases: `guild`, `member`, `user`');
}
if (!args[1]) {
message.channel.send(
`\`\`\`js
${JSON.stringify(data[args[0]])}
\`\`\``
);
} else {
const res = data[args[0]][args[1]];
if (!res) return message.channel.send('Invalid key. Check for typing errors and try again.');
message.channel.send('```' + res + '```');
}
}
}
module.exports = Retrieve;

View file

@ -1,55 +0,0 @@
const Discord = require('discord.js');
const Command = require('../../base/Command.js');
class Avatar extends Command {
constructor (client) {
super(client, {
description: 'View a full-sized image of a person\'s profile picture.',
usage: 'avatar <user>',
examples: '`avatar` - Gets your avatar.\n`avatar emily` - Gets the avatar of the user "emily"',
aliases: ['pfp'],
botPerms: ['EMBED_LINKS']
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
if (!args[0]) {
const embed = this.createEmbed(message.author);
return message.channel.send(embed);
}
let user = message.mentions.users.first();
if (!user && message.guild) {
user = this.client.functions.searchForMembers(message.guild, args[0]);
if (user.length > 1) {
return message.channel.send(
'Found multiple users, please be more specific or @mention the user instead.'
);
}
if (user.length < 1) {
return message.channel.send(
'Specified user couldn\'t be found, check for typing errors.'
);
}
}
user = user[0].user;
const embed = this.createEmbed(user);
return message.channel.send(embed);
}
createEmbed (user) {
const URL = user.avatarURL({format: 'png', dynamic: true, size: 2048});
const embed = new Discord.MessageEmbed()
.setTitle(user.tag)
.setDescription(`**[Avatar URL](${URL})**`)
.setImage(URL);
return embed;
}
}
module.exports = Avatar;