From 41c3b51ed62df9970346aeb84b10a14707558c60 Mon Sep 17 00:00:00 2001 From: Emily J Date: Sun, 18 Oct 2020 11:58:58 +1100 Subject: [PATCH] formatting fixes --- bot/commands/Core/help.js | 20 ++++---- bot/commands/Core/ping.js | 36 ++++++------- bot/commands/Developer/eval.js | 61 +++++++++++----------- bot/commands/Test/lastmessage.js | 22 ++++---- bot/commands/Test/msearch.js | 55 ++++++++++---------- bot/commands/Utility/avatar.js | 86 ++++++++++++++++---------------- bot/events/error.js | 12 ++--- 7 files changed, 144 insertions(+), 148 deletions(-) diff --git a/bot/commands/Core/help.js b/bot/commands/Core/help.js index d3a2067..3b6a3db 100644 --- a/bot/commands/Core/help.js +++ b/bot/commands/Core/help.js @@ -1,17 +1,17 @@ -const Command = require("../../base/Command.js"); +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 ` - Shows detailed information on a specific command.'", - aliases: ["cmds"], - }); - } + 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 ` - Shows detailed information on a specific command.', + aliases: ['cmds'], + }); + } - async run (message, args, data) { // eslint-disable-line no-unused-vars + async run (message, args, data) { // eslint-disable-line no-unused-vars - } + } } module.exports = Help; diff --git a/bot/commands/Core/ping.js b/bot/commands/Core/ping.js index e586ca0..38bdeea 100644 --- a/bot/commands/Core/ping.js +++ b/bot/commands/Core/ping.js @@ -1,24 +1,24 @@ -const Command = require("../../base/Command.js"); +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) + 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; diff --git a/bot/commands/Developer/eval.js b/bot/commands/Developer/eval.js index 8272252..c3d1dbf 100644 --- a/bot/commands/Developer/eval.js +++ b/bot/commands/Developer/eval.js @@ -1,36 +1,37 @@ -const Command = require("../../base/Command.js"); -const Discord = require("discord.js"); +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 ", - 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\`\`\``); + constructor (client) { + super(client, { + description: 'Evaluates arbitrary Javascript.', + usage: 'eval ', + 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; diff --git a/bot/commands/Test/lastmessage.js b/bot/commands/Test/lastmessage.js index a3c60df..4541423 100644 --- a/bot/commands/Test/lastmessage.js +++ b/bot/commands/Test/lastmessage.js @@ -1,17 +1,17 @@ -const Command = require("../../base/Command.js"); +const Command = require('../../base/Command.js'); class Lastmessage extends Command { - constructor (client) { - super(client, { - description: "Grab last message sent to a channel.", - usage: "lastmessage", - }); - } + 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); - } + 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; diff --git a/bot/commands/Test/msearch.js b/bot/commands/Test/msearch.js index bb22037..a13e2f0 100644 --- a/bot/commands/Test/msearch.js +++ b/bot/commands/Test/msearch.js @@ -1,41 +1,36 @@ -const Command = require("../../base/Command.js"); +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'] - }); - } + 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.` - ); - - var mlist = ""; - var count = 0; + async run (message, args, data) { // eslint-disable-line no-unused-vars + if (!args[0]) return message.channel.send('No username provided.'); - this.client.functions.searchForMembers(message.guild, args[0]).forEach((member) => { - if (member) { - mlist += `\`${member.user.tag}\``; - count = count + 1; - } - mlist += "**, **"; - }); + let mlist = ''; + let count = 0; - mlist = mlist.substring(0, mlist.length - 6); + this.client.functions.searchForMembers(message.guild, args[0]).forEach((member) => { + if (member) { + mlist += `\`${member.user.tag}\``; + count = count + 1; + } + mlist += '**, **'; + }); - var mlist1 = `Found ${count} users:\n` + mlist; + mlist = mlist.substring(0, mlist.length - 6); - if (!mlist1) { - return message.channel.send("No users found!"); - }; + const mlist1 = `Found ${count} users:\n` + mlist; - message.channel.send(mlist1); - } + if (!mlist1) return message.channel.send('No users found!'); + + message.channel.send(mlist1); + } } module.exports = Msearch; diff --git a/bot/commands/Utility/avatar.js b/bot/commands/Utility/avatar.js index f992fd7..f883c26 100644 --- a/bot/commands/Utility/avatar.js +++ b/bot/commands/Utility/avatar.js @@ -1,55 +1,55 @@ const Discord = require('discord.js'); -const Command = require("../../base/Command.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 ", - examples: "`avatar` - Gets your avatar.\n`avatar emily` - Gets the avatar of the user 'emily' ", - aliases: ["pfp"], - botPerms: ["EMBED_LINKS"] - }); - } + constructor (client) { + super(client, { + description: 'View a full-sized image of a person\'s profile picture.', + usage: 'avatar ', + 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); - }; + 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(); + 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 && 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.' - ); - }; - }; + if (user.length < 1) { + return message.channel.send( + 'Specified user couldn\'t be found, check for typing errors.' + ); + } + } - user = user[0].user; + 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); + 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; - }; -}; + return embed; + } +} module.exports = Avatar; diff --git a/bot/events/error.js b/bot/events/error.js index 34d6dd0..baca31c 100644 --- a/bot/events/error.js +++ b/bot/events/error.js @@ -1,9 +1,9 @@ module.exports = class { - constructor (client) { - this.client = client; - } + constructor (client) { + this.client = client; + } - async run (error) { - this.client.logger.log(`An error event was sent by Discord.js: \n${JSON.stringify(error)}`, "error"); - } + async run (error) { + this.client.logger.log(`An error event was sent by Discord.js: \n${JSON.stringify(error)}`, 'error'); + } };