diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-23 20:17:13 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-08-23 20:17:13 -0400 |
commit | 5d33e1aa43444850084b4794b7d870e67dbb474e (patch) | |
tree | 3c98cbb49ce896d0ca3e65b13c5cded0f8580359 /src/commands | |
parent | fa9e2fea668f0f1aaa766288599393e6816c58bc (diff) | |
download | tanzanite-5d33e1aa43444850084b4794b7d870e67dbb474e.tar.gz tanzanite-5d33e1aa43444850084b4794b7d870e67dbb474e.tar.bz2 tanzanite-5d33e1aa43444850084b4794b7d870e67dbb474e.zip |
bunch of shit
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/config/features.ts | 56 | ||||
-rw-r--r-- | src/commands/dev/test.ts | 3 | ||||
-rw-r--r-- | src/commands/utilities/calculator.ts | 57 | ||||
-rw-r--r-- | src/commands/utilities/decode.ts | 8 |
4 files changed, 90 insertions, 34 deletions
diff --git a/src/commands/config/features.ts b/src/commands/config/features.ts index 0547bd0..1974297 100644 --- a/src/commands/config/features.ts +++ b/src/commands/config/features.ts @@ -1,29 +1,29 @@ -// import { BushCommand, BushMessage, BushSlashMessage, guildFeatures } from '@lib'; -// import { MessageEmbed } from 'discord.js'; +import { BushCommand, BushMessage, BushSlashMessage, guildFeatures } from '@lib'; +import { MessageEmbed } from 'discord.js'; -// export default class FeaturesCommand extends BushCommand { -// public constructor() { -// super('features', { -// aliases: ['features'], -// category: 'config', -// description: { -// content: 'Toggle features the server.', -// usage: 'features', -// examples: ['features'] -// }, -// slash: true, -// channel: 'guild', -// clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], -// userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] -// }); -// } -// public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { -// if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); -// const featureEmbed = new MessageEmbed().setTitle(`${message.guild.name}'s Features`).setColor(util.colors.default); -// const featureList: string[] = []; -// const enabledFeatures = message.guild.getSetting('enabledFeatures'); -// guildFeatures.forEach(feature => { -// featureList.push(`${}`) -// }) -// } -// } +export default class FeaturesCommand extends BushCommand { + public constructor() { + super('features', { + aliases: ['features'], + category: 'config', + description: { + content: 'Toggle features the server.', + usage: 'features', + examples: ['features'] + }, + slash: true, + channel: 'guild', + clientPermissions: ['SEND_MESSAGES', 'EMBED_LINKS'], + userPermissions: ['SEND_MESSAGES', 'MANAGE_GUILD'] + }); + } + public override async exec(message: BushMessage | BushSlashMessage): Promise<unknown> { + if (!message.guild) return await message.util.reply(`${util.emojis.error} This command can only be used in servers.`); + const featureEmbed = new MessageEmbed().setTitle(`${message.guild.name}'s Features`).setColor(util.colors.default); + const featureList: string[] = []; + const enabledFeatures = await message.guild.getSetting('enabledFeatures'); + guildFeatures.forEach((feature) => { + // featureList.push(`**${feature}:** ${enabledFeatures.includes(feature)? util.emojis.}`); + }); + } +} diff --git a/src/commands/dev/test.ts b/src/commands/dev/test.ts index 151e4a1..aa421cd 100644 --- a/src/commands/dev/test.ts +++ b/src/commands/dev/test.ts @@ -24,7 +24,8 @@ export default class TestCommand extends BushCommand { optional: true } } - ] + ], + superUserOnly: true }); } diff --git a/src/commands/utilities/calculator.ts b/src/commands/utilities/calculator.ts new file mode 100644 index 0000000..5f91dca --- /dev/null +++ b/src/commands/utilities/calculator.ts @@ -0,0 +1,57 @@ +import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib'; +import { MessageEmbed } from 'discord.js'; +import { evaluate } from 'mathjs'; + +export default class CalculatorCommand extends BushCommand { + public constructor() { + super('calculator', { + aliases: ['calculator', 'calc', 'math'], + category: 'utilities', + description: { + content: 'Calculates math expressions.', + usage: 'calculator <expression>', + examples: ['calculator '] + }, + args: [ + { + id: 'expression', + type: 'string', + match: 'rest', + prompt: { + start: 'What would you like to evaluate?', + retry: '{error} Pick something to evaluate.', + optional: false + } + } + ], + slash: true, + slashOptions: [ + { + name: 'expression', + description: 'What would you like to evaluate?', + type: 'STRING', + required: true + } + ], + hidden: true, + clientPermissions: ['SEND_MESSAGES'], + userPermissions: ['SEND_MESSAGES'] + }); + } + public override async exec(message: BushMessage | BushSlashMessage, args: { expression: string }): Promise<unknown> { + const decodedEmbed = new MessageEmbed() + .setTitle(`Calculator`) + .addField('📥 Input', await util.inspectCleanRedactCodeblock(args.expression, 'mma')); + try { + const calculated = evaluate(args.expression); + decodedEmbed + .setColor(util.colors.success) + .addField('📤 Output', await util.inspectCleanRedactCodeblock(calculated.toString(), 'mma')); + } catch (error) { + decodedEmbed + .setColor(util.colors.error) + .addField(`📤 Error Calculating`, await util.inspectCleanRedactCodeblock(`${error.name}: ${error.message}`, 'js')); + } + return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() }); + } +} diff --git a/src/commands/utilities/decode.ts b/src/commands/utilities/decode.ts index 05e988a..a5a4c21 100644 --- a/src/commands/utilities/decode.ts +++ b/src/commands/utilities/decode.ts @@ -99,16 +99,14 @@ export default class DecodeCommand extends BushCommand { const encodeOrDecode = util.capitalizeFirstLetter(message?.util?.parsed?.alias || 'decoded'); const decodedEmbed = new MessageEmbed() .setTitle(`${encodeOrDecode} Information`) - .addField('📥 Input', await util.inspectCleanRedactCodeblock(data, undefined)); + .addField('📥 Input', await util.inspectCleanRedactCodeblock(data)); try { const decoded = Buffer.from(data, from).toString(to); - decodedEmbed - .setColor(util.colors.success) - .addField('📤 Output', await util.inspectCleanRedactCodeblock(decoded, undefined)); + decodedEmbed.setColor(util.colors.success).addField('📤 Output', await util.inspectCleanRedactCodeblock(decoded)); } catch (error) { decodedEmbed .setColor(util.colors.error) - .addField(`📤 Error ${encodeOrDecode.slice(1)}ing`, await util.inspectCleanRedactCodeblock(error.stack, undefined)); + .addField(`📤 Error ${encodeOrDecode.slice(1)}ing`, await util.inspectCleanRedactCodeblock(error?.stack ?? error)); } return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() }); } |