From 3f09ea7f76e75b81cd7ecb6353a111922d8affcb Mon Sep 17 00:00:00 2001 From: Emily J Date: Wed, 21 Oct 2020 18:06:52 +1100 Subject: [PATCH] commands! --- bot/commands/Configuration/userprefix.js | 30 ++++++++++++++++++ bot/commands/Developer/eval.js | 39 ++++++++++++++++++++++++ bot/commands/Developer/reload.js | 24 +++++++++++++++ bot/commands/Test/hello.js | 4 +-- 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 bot/commands/Configuration/userprefix.js create mode 100644 bot/commands/Developer/eval.js create mode 100644 bot/commands/Developer/reload.js diff --git a/bot/commands/Configuration/userprefix.js b/bot/commands/Configuration/userprefix.js new file mode 100644 index 0000000..2b681dc --- /dev/null +++ b/bot/commands/Configuration/userprefix.js @@ -0,0 +1,30 @@ +module.exports = class { + constructor (name, category) { + this.name = name, + this.category = category, + this.enabled = true, + this.guildOnly = false, + this.devOnly = false, + this.aliases = [], + this.userPerms = [], + this.botPerms = [], + this.cooldown = 10000, + this.help = { + description: 'Sets your own personal prefix for woomy, that works in all servers and DM\'s.', + usage: 'userprefix` ', + examples: 'userprefix w! - sets your personal prefix to woomy' + }; + } + + async run (client, message, args, data) { + if (!args[0]) { + return message.channel.createMessage( + `Your prefix for Woomy is currently: \`${data.user.prefix}\`` + ); + } + + await client.db.updateUser(message.author.id, 'prefix', args[0]); + + message.channel.createMessage(`Your personal prefix has been set to: \`${args[0]}\``); + } +}; \ No newline at end of file diff --git a/bot/commands/Developer/eval.js b/bot/commands/Developer/eval.js new file mode 100644 index 0000000..54fa63a --- /dev/null +++ b/bot/commands/Developer/eval.js @@ -0,0 +1,39 @@ +module.exports = class { + constructor (name, category) { + this.name = name, + this.category = category, + this.enabled = true, + this.guildOnly = false, + this.devOnly = true, + this.aliases = [], + this.userPerms = [], + this.botPerms = [], + this.cooldown = 0, + this.help = { + description: 'Evalutes and executes JavaScript code.', + usage: 'eval ', + 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.helpers.clean(evaled); + const MAX_CHARS = 3 + 2 + clean.length + 3; + if (MAX_CHARS > 2000) { + message.channel.createMessage(undefined, { file: Buffer.from(clean), name: 'EVAL_SUCCESS.txt' }); + } + message.channel.createMessage(`\`\`\`js\n${clean}\n\`\`\``); + } catch (err) { + const e = await client.helpers.clean(err); + const MAX_CHARS = 3 + 2 + e.length + 3; + if (MAX_CHARS > 2000) { + return message.channel.createMessage(undefined, { file: Buffer.from(e), name: 'EVAL_ERROR.txt' }); + } + + message.channel.createMessage(`\`\`\`xl\n${e}\n\`\`\``); + } + } +}; \ No newline at end of file diff --git a/bot/commands/Developer/reload.js b/bot/commands/Developer/reload.js new file mode 100644 index 0000000..eb0bfe2 --- /dev/null +++ b/bot/commands/Developer/reload.js @@ -0,0 +1,24 @@ +module.exports = class { + constructor (name, category) { + this.name = name, + this.category = category, + this.enabled = true, + this.guildOnly = false, + this.devOnly = true, + this.aliases = [], + this.userPerms = [], + this.botPerms = [], + this.cooldown = 0, + this.help = { + description: 'Reloads all commands and event modules.', + usage: 'reload', + examples: undefined + }; + } + + run (client, message, args, data) { //eslint-disable-line no-unused-vars + client.commandLoader.reloadCommands(); + client.eventLoader.reloadEventModules(); + message.channel.createMessage('All commands and event modules have been reloaded!'); + } +}; \ No newline at end of file diff --git a/bot/commands/Test/hello.js b/bot/commands/Test/hello.js index 5a8bc2c..7fb3a8a 100644 --- a/bot/commands/Test/hello.js +++ b/bot/commands/Test/hello.js @@ -6,7 +6,7 @@ module.exports = class { this.guildOnly = false, this.devOnly = false, this.aliases = [], - this.userPerms = [], + this.userPerms = ['administrator'], this.botPerms = [], this.cooldown = 2000, this.help = { @@ -17,6 +17,6 @@ module.exports = class { } run (client, message, args, data) { // eslint-disable-line no-unused-vars - return client.createMessage(message.channel.id, `Hello, ${message.author}!`); + return message.channel.createMessage(`Hello, ${message.author.mention}!`); } }; \ No newline at end of file