diff --git a/src/commands/generate.ts b/src/commands/generate.ts index c45aa99..1cbdf01 100644 --- a/src/commands/generate.ts +++ b/src/commands/generate.ts @@ -1,7 +1,9 @@ import { CacheType, Interaction } from "discord.js"; import { v4 as uuidV4 } from "uuid"; +import crypto from "crypto"; const RANDOM_UUID = "RANDOM_UUID"; +const SECRET_STRING = "SECRET_STRING"; export const generateCommand = { name: "generate", @@ -12,7 +14,16 @@ export const generateCommand = { description: "The type of value to generate", required: true, type: 3, - choices: [{ name: "Random UUID", value: RANDOM_UUID }], + choices: [ + { name: "Random UUID", value: RANDOM_UUID }, + { name: "Secret String", value: SECRET_STRING }, + ], + }, + { + name: "length", + description: "The length of the secret string (default: 32)", + required: false, + type: 4, }, ], @@ -30,6 +41,11 @@ export const generateCommand = { await interaction.reply(uuidV4()); break; } + case SECRET_STRING: { + const len = (options.get("length")?.value as number) || 32; + await interaction.reply(crypto.randomBytes(len).toString("hex")); + break; + } } } },