From 00d3ea29997e4d73811b09c2a5c863a0d38dcb59 Mon Sep 17 00:00:00 2001 From: codepupper Date: Sun, 10 Nov 2019 21:50:18 +0100 Subject: [PATCH] finishing touches --- DiscordEvents/message.js | 22 +++++++++++++- DiscordModules/Developers/exec.js | 28 +++++++++++++++++ DiscordModules/General/bug.js | 48 ++++++++++++++++++++++++++++++ DiscordModules/General/suggest.js | 48 ++++++++++++++++++++++++++++++ index.js | 2 +- json.sqlite | Bin 16384 -> 16384 bytes package-lock.json | 43 ++++++++++++++++++++++++++ package.json | 2 ++ run.bat | 5 ++++ src/client/Client.js | 1 - 10 files changed, 196 insertions(+), 3 deletions(-) create mode 100644 DiscordModules/Developers/exec.js create mode 100644 DiscordModules/General/bug.js create mode 100644 DiscordModules/General/suggest.js create mode 100644 run.bat diff --git a/DiscordEvents/message.js b/DiscordEvents/message.js index 67a1b28..f52725e 100755 --- a/DiscordEvents/message.js +++ b/DiscordEvents/message.js @@ -3,6 +3,9 @@ const { table } = require('quick.db'); const Servers = new table('servers'); const Users = new table('users'); const Backend = new table('backend'); +const Trello = require('trello'); +const config = require('../config'); +const trello = new Trello(config.trello.key, config.trello.token); module.exports = { name: 'message', run: async (client, msg) => { @@ -39,6 +42,7 @@ module.exports = { channel: msg.channel, author: msg.author, member: msg.member, + trello, db: { users: Users, servers: Servers, backend: Backend }, utils: require('../utils'), config: require('../config'), @@ -77,7 +81,23 @@ module.exports = { timestamps.set(msg.author.id, now); setTimeout(() => timestamps.delete(msg.author.id), cooldownAmount); - cmd.command(ctx).then(() => {}).catch(console.error); + cmd.command(ctx).then(() => {}).catch((err) => { + trello + .addCard( + cmd.name + ' | ' + err.message, + `Full Error: + ${err} + + Author: ${msg.author.tag} (${msg.author.id}) + Server: ${msg.guild.name} (${msg.guild.id})`, + config.trello.boards.errors + ) + .then((r) => { + trello.addLabelToCard(r.id, config.trello.labels.errors).catch((error) => console.log(error)); + }) + .catch((err) => console.log(err)); + console.warn(err.message); + }); } } }; diff --git a/DiscordModules/Developers/exec.js b/DiscordModules/Developers/exec.js new file mode 100644 index 0000000..be6ceb6 --- /dev/null +++ b/DiscordModules/Developers/exec.js @@ -0,0 +1,28 @@ +const Command = require('../../src/structures/Command'); +const exec = require('shell-exec'); +module.exports = class Exec extends Command { + constructor() { + super({ + name: 'exec', + description: 'Execute shell commands', + aliases: [ 'ex' ], + module: 'Developers', + cooldown: 1, + guildOnly: false, + developerOnly: true, + nsfw: false + }); + } + + async command(ctx) { + const trying = await ctx.send('Attempting to execute ' + ctx.utils.format.bold(ctx.args.join(' '))); + + await exec(ctx.args.join(' ')) + .then((r) => { + trying.edit('```bash\n' + r.stdout + '```'); + }) + .catch((error) => { + trying.edit('Failed to execute ' + ctx.utils.format.bold(ctx.args.join(' '))); + }); + } +}; diff --git a/DiscordModules/General/bug.js b/DiscordModules/General/bug.js new file mode 100644 index 0000000..cfcb453 --- /dev/null +++ b/DiscordModules/General/bug.js @@ -0,0 +1,48 @@ +const Command = require('../../src/structures/Command'); +const D = require('discord.js'); +module.exports = class Bug extends Command { + constructor() { + super({ + name: 'bug', + description: 'Report a Bug in the bot', + aliases: [ 'report', 'bugreport' ], + module: 'General', + cooldown: 10, + guildOnly: false, + developerOnly: false, + nsfw: false + }); + } + + async command(ctx) { + /* throw new Error('Testing'); */ + let abuse = new D.MessageEmbed() + .setTitle('Misuse of Command') + .setDescription( + `Please make sure to make your Suggestion as Detailed as possible.\n\nAbuse of this command will lead to complete denial of command usage.` + ); + if (ctx.args.length < 1) { + return m.channel.send(abuse); + } + + ctx.trello + .addCard( + ctx.args.join(' '), + ` + Author: ${ctx.author.tag} (${ctx.author.id}) + Server: ${ctx.guild.name} (${ctx.guild.id})`, + ctx.config.trello.boards.bugs + ) + .then((r) => { + ctx.trello.addLabelToCard(r.id, ctx.config.trello.labels.bugs).catch(console.error); + let reply = new D.MessageEmbed() + .setTitle('Report Received') + .setColor(ctx.config.color) + .setDescription(ctx.args.join(' ')) + .addField('URL', r.url, true) + .setThumbnail(ctx.client.user.avatarURL()); + + ctx.send(reply); + }); + } +}; diff --git a/DiscordModules/General/suggest.js b/DiscordModules/General/suggest.js new file mode 100644 index 0000000..6436b37 --- /dev/null +++ b/DiscordModules/General/suggest.js @@ -0,0 +1,48 @@ +const Command = require('../../src/structures/Command'); +const D = require('discord.js'); +module.exports = class Suggest extends Command { + constructor() { + super({ + name: 'suggest', + description: 'Suggest something for the Bot', + aliases: [ 'sug', 'suggestion' ], + module: 'General', + cooldown: 10, + guildOnly: false, + developerOnly: false, + nsfw: false + }); + } + + async command(ctx) { + /* throw new Error('Testing'); */ + let abuse = new D.MessageEmbed() + .setTitle('Misuse of Command') + .setDescription( + `Please make sure to make your Suggestion as Detailed as possible.\n\nAbuse of this command will lead to complete denial of command usage.` + ); + if (ctx.args.length < 1) { + return m.channel.send(abuse); + } + + ctx.trello + .addCard( + ctx.args.join(' '), + ` + Author: ${ctx.author.tag} (${ctx.author.id}) + Server: ${ctx.guild.name} (${ctx.guild.id})`, + ctx.config.trello.boards.suggestions + ) + .then((r) => { + ctx.trello.addLabelToCard(r.id, ctx.config.trello.labels.suggestions).catch(console.error); + let reply = new D.MessageEmbed() + .setTitle('Suggestion Received') + .setColor(ctx.config.color) + .setDescription(ctx.args.join(' ')) + .addField('URL', r.url, true) + .setThumbnail(ctx.client.user.avatarURL()); + + ctx.send(reply); + }); + } +}; diff --git a/index.js b/index.js index d6f17dc..d3bc197 100755 --- a/index.js +++ b/index.js @@ -2,8 +2,8 @@ const Client = require('./src/index'); const config = require('./config'); const { log } = require('./utils/index'); const yiff = require('yiff'); -yiff.sheri.setToken(config.api.sheri); +yiff.sheri.setToken(config.api.sheri); const { util } = require('discord.js'); util.fetchRecommendedShards(config.token).then(async (count) => { diff --git a/json.sqlite b/json.sqlite index 7dc0a616d6addc4a79a58c07ca37b32cef47b5a0..59860736b205dae9dbdeba2a2fa4ee6d9702c24c 100755 GIT binary patch delta 25 gcmZo@U~Fh$oFL7}J5k1&k#}RlRXaxW$!7Ma0AaTW=l}o! delta 25 gcmZo@U~Fh$oFL7}Gf~Ewk!NGVRXawr$!7Ma0AZI0