misc.roll: interaction command per request

This commit is contained in:
Cynthia Foxwell 2025-02-27 16:14:19 -07:00
parent cb503762a7
commit d56f8b56f7
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -1,4 +1,6 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const {ApplicationCommandOptionTypes} = require("#util/dconstants.js");
const roll = new Command("roll");
roll.category = "misc";
@ -22,3 +24,19 @@ roll.callback = function (msg, line) {
return `:game_die: (d${line}): ${1 + res}`;
};
hf.registerCommand(roll);
const rollInteraction = new InteractionCommand("roll");
rollInteraction.helpText = "Roll a dice";
rollInteraction.options.input = {
name: "sides",
type: ApplicationCommandOptionTypes.NUMBER,
description: "How many sides to pick from",
required: false,
default: 6,
};
rollInteraction.callback = async function (interaction) {
const sides = this.getOption(interaction, "sides");
return roll.callback(interaction, sides);
};
hf.registerCommand(rollInteraction);