diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-17 10:25:46 -0400 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-07-17 10:25:46 -0400 |
commit | d1724227abfb8f0fcd9e573f7e9772cf0be8257a (patch) | |
tree | 52c9dbae1fbbbd3c777d9c16ab643c477141ae21 /src/commands/utilities/hash.ts | |
parent | 53d2b18f7f73d5696fb7cd86d1c164a790dfdcc3 (diff) | |
download | tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.tar.gz tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.tar.bz2 tanzanite-d1724227abfb8f0fcd9e573f7e9772cf0be8257a.zip |
honestly no idea what I did at this point
Diffstat (limited to 'src/commands/utilities/hash.ts')
-rw-r--r-- | src/commands/utilities/hash.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/commands/utilities/hash.ts b/src/commands/utilities/hash.ts new file mode 100644 index 0000000..4b5b01c --- /dev/null +++ b/src/commands/utilities/hash.ts @@ -0,0 +1,42 @@ +import crypto from 'crypto'; +import { Constants } from 'discord-akairo'; +import got from 'got'; +import { BushCommand, BushMessage } from '../../lib'; + +export default class HashCommand extends BushCommand { + constructor() { + super('hash', { + aliases: ['hash'], + category: 'utilities', + description: { + content: 'Gets the file hash of the given discord link', + usage: 'hash <file url>', + examples: ['hash https://cdn.discordapp.com/emojis/782630946435366942.png?v=1'] //nice + }, + args: [ + { + id: 'url', + type: Constants.ArgumentTypes.URL, + match: Constants.ArgumentMatches.PHRASE, + prompt: { + start: 'What url would you like to find the hash of?', + retry: '{error} Enter a valid url.' + } + } + ], + clientPermissions: ['SEND_MESSAGES'] + }); + } + + public async exec(message: BushMessage, { url }: { url: string }): Promise<void> { + try { + const req = await got.get(url); + const rawHash = crypto.createHash('md5'); + rawHash.update(req.rawBody.toString('binary')); + const hash = rawHash.digest('hex'); + await message.util.reply(`\`${hash}\``); + } catch { + await message.util.reply('Unable to calculate hash.'); + } + } +} |