Skip to content

Commit

Permalink
feat: Added Command to Generate Secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
bmonish committed May 21, 2024
1 parent 2011f0f commit fe9fe90
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/commands/generate.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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,
},
],

Expand All @@ -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;
}
}
}
},
Expand Down

0 comments on commit fe9fe90

Please sign in to comment.