diff --git a/commands/interaction/context/bottom.js b/commands/interaction/context/bottom.js new file mode 100644 index 0000000..4e84c9c --- /dev/null +++ b/commands/interaction/context/bottom.js @@ -0,0 +1,32 @@ +const { Constants } = require('detritus-client'); +const { InteractionCallbackTypes, ApplicationCommandTypes, MessageFlags } = Constants; + +const { createEmbed } = require('../../../labscore/utils/embed'); +const { codeblock } = require('../../../labscore/utils/markdown'); + +const { decode } = require('bottomify') + +module.exports = { + name: 'Decode Bottom', + type: ApplicationCommandTypes.MESSAGE, + run: async (context, args) => { + try{ + const { message } = args; + + let decodedMessage = decode(message.content) + + await context.respond({data: { flags: MessageFlags.EPHEMERAL, embeds: [ + createEmbed("default", context, { + description: codeblock("py", [decodedMessage]) + }) + ] }, type: InteractionCallbackTypes.CHANNEL_MESSAGE_WITH_SOURCE}) + + }catch(e){ + console.log(e) + await context.editOrRespond({ + embeds: [createEmbed("error", context, "Unable to decode message.")], + flags: MessageFlags.EPHEMERAL + }) + } + }, +}; \ No newline at end of file diff --git a/package.json b/package.json index e57c8d7..fc7384c 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "author": "", "license": "ISC", "dependencies": { + "bottomify": "^0.3.0", "detritus-client": "^0.17.0-beta.16", "dotenv": "^16.0.1", "emoji-aware": "^3.1.0",