aboutsummaryrefslogtreecommitdiff
path: root/src/commands/utilities/decode.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-26 15:33:09 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-07-26 15:33:09 -0400
commit37a121011bf147ea1e56b299b7e2b5dfe3574532 (patch)
tree40051dedaaae4ba6ab8647cefd3a7cda75e47843 /src/commands/utilities/decode.ts
parent88e68875030086f5acf2c4295280e1b370242ec7 (diff)
downloadtanzanite-37a121011bf147ea1e56b299b7e2b5dfe3574532.tar.gz
tanzanite-37a121011bf147ea1e56b299b7e2b5dfe3574532.tar.bz2
tanzanite-37a121011bf147ea1e56b299b7e2b5dfe3574532.zip
fix: refactored eval, sanitize decode, refactor price and fix trying to use an emoji as a color
Diffstat (limited to 'src/commands/utilities/decode.ts')
-rw-r--r--src/commands/utilities/decode.ts36
1 files changed, 7 insertions, 29 deletions
diff --git a/src/commands/utilities/decode.ts b/src/commands/utilities/decode.ts
index 97ff444..aa3d455 100644
--- a/src/commands/utilities/decode.ts
+++ b/src/commands/utilities/decode.ts
@@ -89,43 +89,21 @@ export default class DecodeCommand extends BushCommand {
}
public async exec(
- message: BushMessage,
+ message: BushMessage | AkairoMessage,
{ from, to, data }: { from: BufferEncoding; to: BufferEncoding; data: string }
): Promise<unknown> {
- const encodeOrDecode = message?.util?.parsed?.alias?.charAt(0).toUpperCase() + message?.util?.parsed?.alias?.slice(1);
+ const encodeOrDecode = util.capitalizeFirstLetter(message?.util?.parsed?.alias) || 'Decoded';
const decodedEmbed = new MessageEmbed()
.setTitle(`${encodeOrDecode} Information`)
- .addField('📥 Input', await this.client.util.codeblock(data, 1024));
+ .addField('📥 Input', await util.inspectCleanRedactCodeblock(data, null));
try {
const decoded = Buffer.from(data, from).toString(to);
- decodedEmbed
- .setColor(this.client.util.colors.success)
- .addField('📤 Output', await this.client.util.codeblock(decoded, 1024));
- } catch (error) {
- decodedEmbed
- .setColor(this.client.util.colors.error)
- .addField(`📤 Error ${encodeOrDecode.slice(1)}ing`, await this.client.util.codeblock(error.stack, 1024));
- }
- return await message.util.send({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() });
- }
-
- public async execSlash(
- message: AkairoMessage,
- { from, to, data }: { from: BufferEncoding; to: BufferEncoding; data: string }
- ): Promise<unknown> {
- const decodedEmbed = new MessageEmbed()
- .setTitle(`Decoded Information`)
- .addField('📥 Input', await this.client.util.codeblock(data, 1024));
- try {
- const decoded = Buffer.from(data, from).toString(to);
- decodedEmbed
- .setColor(this.client.util.colors.success)
- .addField('📤 Output', await this.client.util.codeblock(decoded, 1024));
+ decodedEmbed.setColor(util.colors.success).addField('📤 Output', await util.inspectCleanRedactCodeblock(decoded, null));
} catch (error) {
decodedEmbed
- .setColor(this.client.util.colors.error)
- .addField(`📤 Error decoding`, await this.client.util.codeblock(error.stack, 1024));
+ .setColor(util.colors.error)
+ .addField(`📤 Error ${encodeOrDecode.slice(1)}ing`, await util.inspectCleanRedactCodeblock(error.stack, null));
}
- return await message.interaction.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() });
+ return await message.util.reply({ embeds: [decodedEmbed], allowedMentions: AllowedMentions.none() });
}
}