From ba0448c9058d4e30307bd1187a91a739d327b91d Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Sat, 11 Apr 2020 19:30:51 +1000 Subject: [PATCH] Did lots of things --- commands/avatar.js | 39 ------------------------------- commands/emoji.js | 2 +- commands/eval.js | 3 ++- commands/help.js | 54 +++++++++++++++++++++++-------------------- commands/invite.js | 20 ++++++++++++++++ commands/level.js | 2 +- commands/ping.js | 2 +- commands/pride.js | 47 ++++++++++++++++++------------------- commands/ship.js | 15 ++++++++---- commands/support.js | 30 +++++++++++++----------- helpers/_functions.js | 13 +++++++++++ 11 files changed, 115 insertions(+), 112 deletions(-) delete mode 100644 commands/avatar.js create mode 100644 commands/invite.js diff --git a/commands/avatar.js b/commands/avatar.js deleted file mode 100644 index 6288ca5..0000000 --- a/commands/avatar.js +++ /dev/null @@ -1,39 +0,0 @@ -exports.conf = { - enabled: true, - guildOnly: false, - aliases: [], - permLevel: 'User', - requiredPerms: ['EMBED_LINKS'] -}; - -exports.help = { - name: 'avatar', - category: 'Utility', - description: 'Gives you the specified users avatar.', - usage: 'avatar ', - params: '' -}; - -exports.run = (client, message, args) => { - let user = message.mentions.users.first(); - let users; - if (!args[0] || !message.guild) { - user = message.author; - }; - - if (!user && message.guild) { - users = client.searchForMembers(message.guild, args[0]); - if (users.length > 1) { - return message.channel.send( - '<:error:466995152976871434> Found multiple users, please be more specific or mention the user instead.' - ); - } else if (users.length == 0) { - return message.channel.send( - "<:error:466995152976871434> That user doesn't seem to exist, try again!" - ); - }; - user = users[0]; - user = user.user; - } - message.channel.send(`**${user.tag}'s** avatar is: ${user.avatarURL({format: 'png', dynamic: true, size: 2048})}`); -}; \ No newline at end of file diff --git a/commands/emoji.js b/commands/emoji.js index b95bbea..b42bc56 100644 --- a/commands/emoji.js +++ b/commands/emoji.js @@ -11,7 +11,7 @@ exports.help = { category: 'Utility', description: 'Enlarges and links an custom emoji', usage: 'emoji [emoji]', - params: '`[emoji] - Discord emoji you want to enlarge.' + params: '`[emoji] - Custom emoji you want to enlarge.' }; exports.run = async (client, message, args) => { diff --git a/commands/eval.js b/commands/eval.js index b3efc82..e7f6684 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -44,6 +44,7 @@ exports.run = async (client, message, args, level, data) => { return } - message.channel.send(`\`ERROR\` \`\`\`xl\n${await errclean}\n\`\`\``) + message.author.send(`\`ERROR\` \`\`\`xl\n${await errclean}\n\`\`\``) + message.react('⚠️') } } diff --git a/commands/help.js b/commands/help.js index f32dc9e..0231028 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,7 +1,7 @@ exports.conf = { enabled: true, guildOnly: false, - aliases: ['commands', 'cmds', 'halp'], + aliases: ['commands', 'cmds'], permLevel: 'User', requiredPerms: ['EMBED_LINKS'], cooldown: 2000 @@ -9,10 +9,10 @@ exports.conf = { exports.help = { name: 'help', - category: 'General', - description: 'Sends you a list of Woomy\'s commands.', - usage: '`help` - Lists all commands.\n`help ` - Receive more information on a command.', - examples: '`help`\n`help roleinfo`' + category: 'Bot', + description: 'Lists all commands Woomy has, what they do, and how to use them.', + usage: '`help` - Lists all commands.\n`help ` - Show detailed information on how to use the specified command.', + parameters: '`command` - The name of the command you want more information on.' } const Discord = require('discord.js') @@ -20,17 +20,21 @@ exports.run = (client, message, args, level, data) => { const embed = new Discord.MessageEmbed() embed.setColor(client.embedColour(message.guild)) - const prefixes = [data.user.prefix] - if (message.guild && data.user.prefix !== data.guild.prefix) { - prefixes.push(data.guild.prefix) - } - prefixes.push('@Woomy') - - const categories = [] - if (!args[0]) { - embed.setTitle('Woomy Commands') - embed.setDescription(`• Prefixes: ${'`' + prefixes.join('`, `') + '`'}\n• Use \`help \` to recieve more information about a command!\n• [Join my support server](https://discord.gg/HCF8mdv)`) + const categories = [] + let uPrefix = '`' + data.user.prefix + '`' + let gPrefix = '`' + data.guild.prefix + '`' + + if (client.config.defaultPrefix === data.user.prefix) { + uPrefix = 'None set, use: `~myprefix' + } + + if (client.config.defaultPrefix === data.guild.prefix) { + gPrefix = 'None set, use: `~prefix`' + } + + embed.setTitle('Woomy Help') + embed.setDescription(`**Prefixes**\n» Default: \`${client.config.defaultPrefix}\`\n» Server: ${gPrefix}\n» Personal: ${uPrefix}\n\n» [Join my discord server](https://discord.gg/HCF8mdv) if you need help!\n» Use \`help \` to recieve more information about a command!`) const commands = client.commands commands.forEach((cmd) => { @@ -44,14 +48,13 @@ exports.run = (client, message, args, level, data) => { categories.sort().forEach((cat) => { const filtered = commands.filter((cmd) => cmd.help.category === cat) - embed.addField(cat, filtered.map((cmd) => '`' + cmd.help.name + '`').join(', ')) + embed.addField('**' + cat + '**', filtered.map((cmd) => '`' + cmd.help.name + '`').join(', '), true) }) if (message.guild && data.guild.customCommands.length > 0) { - embed.addField('Custom', data.guild.customCommands.map((cmd) => '`' + cmd.name + '`').join(' ')) + embed.addField('**Custom**', data.guild.customCommands.map((cmd) => '`' + cmd.name + '`').join(' '), true) } - embed.addField('Invite', '[Invite](https://discordapp.com/oauth2/authorize?client_id=435961704145485835&permissions=8&scope=bot) | [Discord Server](https://discord.gg/HCF8mdv)') return message.channel.send(embed) } else { const command = args.shift().toLowerCase() @@ -60,23 +63,24 @@ exports.run = (client, message, args, level, data) => { return message.channel.send('Command/alias doesn\'t exist') } - let aliases + let aliases = '' if (cmd.conf.aliases.length > 0) { aliases = '`' + cmd.conf.aliases.join('`, `') + '`' } - const desc = cmd.help.description + `\n\n**You need the \`${cmd.conf.permLevel}\` rank to run this command! This command has a cooldown of \`${cmd.conf.cooldown / 1000}\` seconds per user.**` - embed.setTitle(cmd.help.category.toLowerCase() + ':' + cmd.help.name) - embed.setDescription(desc) + embed.setDescription(cmd.help.description) embed.addField('**Usage**', cmd.help.usage) - if (cmd.help.examples.length > 0) { - embed.addField('**Examples**', cmd.help.examples) - } if (aliases) { embed.addField('**Aliases**', aliases) } + if (cmd.help.parameters.length > 0) { + embed.addField('**Parameters**', cmd.help.parameters) + } + embed.addField('**Rank required**', cmd.conf.permLevel, true) + embed.addField('**Server only**', cmd.conf.guildOnly, true) + embed.addField('**Cooldown**', cmd.conf.cooldown / 1000 + ' seconds', true) embed.setFooter('< > = optional, [ ] = required. Don\'t include the brackets in the command itself!') message.channel.send(embed) } diff --git a/commands/invite.js b/commands/invite.js new file mode 100644 index 0000000..2d9b38f --- /dev/null +++ b/commands/invite.js @@ -0,0 +1,20 @@ +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: 'User', + requiredPerms: [], + cooldown: 2000 +} + +exports.help = { + name: 'invite', + category: 'Bot', + description: 'Sends a link to my support/development server.', + usage: 'invite', + parameters: '' +} + +exports.run = async (client, message, args, level, data) => { + message.channel.send(`Here you go! I hope you enjoy using me ^-^\n`) +} diff --git a/commands/level.js b/commands/level.js index fda1e4e..e0b68a4 100644 --- a/commands/level.js +++ b/commands/level.js @@ -9,7 +9,7 @@ exports.conf = { exports.help = { name: 'level', - category: 'Utility', + category: 'Bot', description: 'Returns your permission level.', usage: 'level', params: '' diff --git a/commands/ping.js b/commands/ping.js index ae1dc3b..6fd6b28 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -9,7 +9,7 @@ exports.conf = { exports.help = { name: 'ping', - category: 'Utility', + category: 'Bot', description: 'Displays bot latency in miliseconds.', usage: 'ping', params: '' diff --git a/commands/pride.js b/commands/pride.js index 21d2232..78f7a45 100644 --- a/commands/pride.js +++ b/commands/pride.js @@ -1,17 +1,32 @@ +exports.conf = { + enabled: true, + guildOnly: false, + aliases: ['flag'], + permLevel: 'User', + requiredPerms: ['ATTACH_FILES'], + cooldown: 15000 +} + +exports.help = { + name: 'pride', + category: 'Fun', + description: 'Adds a pride flag ring to your avatar. Available flags are lesbian, gay, bisexual, pansexual, trans, asexual, aromantic and ally. Generator created by [Demirramon.](https://demirramon.com/)', + usage: '`pride [flag]` - Adds a pride flag overlay to your avatar.\n`pride -g [flag]` - Adds a pride flag gradient on your avatar.', + parameters: '`flag` - What flag you want to add to your avatar (options listed above)\n`-g` - Add this to the start of the command to turn the flag into a gradient.' +} + const url = 'https://demirramon.com/gen/pride.png' const Discord = require('discord.js') exports.run = (client, message, args) => { - const flag = args[0].toLowerCase() + const flag = args[0] if (!flag) { - return message.channel.send( - `<:error:466995152976871434> No message provided. Usage: \`${client.commands.get('pride').help.usage}\`` - ) + return message.channel.send(client.userError(exports, 'Missing argument, the `flag` argument is required!')) } const available = ['lesbian', 'gay', 'bisexual', 'pansexual', 'trans', 'asexual', 'aromantic', 'ally'] - if (!available.includes(flag)) { - return message.channel.send(`This flag isn't available. Available flags: \`${available.join('`, `')}\``) + if (!available.includes(flag.toLowerCase())) { + return message.channel.send(`This flag isn't available, sorry ;~;\nAvailable flags: \`${available.join('`, `')}\``) } let gradient = 'false' @@ -21,7 +36,7 @@ exports.run = (client, message, args) => { message.channel.startTyping() - const params = `image=${message.author.avatarURL({ format: 'png', size: 2048 })}&flag=${flag}&full=true&gradient=${gradient}&background=false&fit=true&v=2019-08-07` + const params = `image=${message.author.avatarURL({ format: 'png', size: 2048 })}&flag=${flag.toLowerCase()}&full=true&gradient=${gradient}&background=false&fit=true&v=2019-08-07` try { message.channel.stopTyping() @@ -31,21 +46,3 @@ exports.run = (client, message, args) => { message.channel.send(`<:error:466995152976871434> Error when generating image: \`${err}\``) } } - -exports.conf = { - enabled: true, - guildOnly: false, - aliases: ['flag'], - permLevel: 'User', - requiredPerms: ['ATTACH_FILES'], - cooldown: 20000 -} - -exports.help = { - name: 'pride', - category: 'Fun', - description: 'Adds a pride flag ring to your avatar. Available flags are lesbian, gay, bisexual, pansexual, trans, asexual, aromantic and ally. Generator created by [Demirramon.](https://demirramon.com/)', - flags: '`-g` - Makes the overlay a gradient.', - usage: '`pride [flag]` - Adds a pride flag overlay to your avatar.\n`pride [flag] -g` - Adds a pride flag gradient on your avatar.', - examples: '`pride trans`\n`pride lesbian -g`' -} diff --git a/commands/ship.js b/commands/ship.js index ba6693f..9db97cc 100644 --- a/commands/ship.js +++ b/commands/ship.js @@ -4,15 +4,16 @@ exports.conf = { guildOnly: false, aliases: [], permLevel: 'User', - requiredPerms: [] + requiredPerms: [], + cooldown: 2000 } exports.help = { name: 'ship', category: 'Fun', description: 'Ship two people together <3', - usage: 'ship [name/user] [name/user]', - params: '' + usage: 'ship `[name1]` `[name2]`', + parameters: '`name1` The name of the first person you want to ship.\n `name` The name of the second person you want to ship.' } const { MessageEmbed } = require('discord.js') @@ -28,8 +29,12 @@ exports.run = async (client, message, args, level, data) => { '💜' ] - if (args.length < 2) { - return message.channel.send('<:error:466995152976871434> Please include two names/users.') + if (!args[0]) { + return message.channel.send(client.userError(exports, 'Missing argument, the `name1` argument is required!')) + } + + if (!args[1]) { + return message.channel.send(client.userError(exports, 'Missing argument, the `name2` argument is required!')) } const firstName = args[0] diff --git a/commands/support.js b/commands/support.js index 4c24c1b..57cb185 100644 --- a/commands/support.js +++ b/commands/support.js @@ -1,18 +1,20 @@ exports.conf = { - enabled: true, - guildOnly: false, - aliases: [], - permLevel: 'User', - requiredPerms: [] -}; + enabled: true, + guildOnly: false, + aliases: [], + permLevel: 'User', + requiredPerms: [], + cooldown: 2000 +} exports.help = { - name: 'support', - category: 'Utility', - description: "Sends a link to my support/development server.", - usage: 'support' -}; + name: 'support', + category: 'Bot', + description: 'Sends a link to my support/development server.', + usage: 'support', + parameters: '' +} -exports.run = async (client, message, args, level, data) =>{ - message.channel.send('Use this link to join my support server: https://discord.gg/' + client.config.support.id); -}; \ No newline at end of file +exports.run = async (client, message, args, level, data) => { + message.channel.send('Here you go! Hopefully we can help you here :3 https://discord.gg/HCF8mdv') +} diff --git a/helpers/_functions.js b/helpers/_functions.js index 1e48de9..adfc714 100644 --- a/helpers/_functions.js +++ b/helpers/_functions.js @@ -1,3 +1,4 @@ +const { MessageEmbed } = require('discord.js') const mongoose = require('mongoose') const Guild = require('../models/guild') const User = require('../models/user') @@ -131,6 +132,18 @@ module.exports = client => { return false } + // Creates an embed for when commands are used incorrectly + client.userError = (cmd, err) => { + const embed = new MessageEmbed() + embed.setColor('#EF5350') + embed.setTitle(cmd.help.name + ':' + cmd.help.category.toLowerCase()) + embed.setDescription(err) + embed.addField('**Usage**', cmd.help.usage) + embed.addField('**Parameters**', cmd.help.parameters) + embed.setFooter(`Run 'help ${cmd.help.name}' for more information.`) + return embed + } + // Clean up input to remove @everyone, token, etc client.clean = async (client, text) => { if (text && text.constructor.name === 'Promise') {