Initial version of bot

This commit is contained in:
2025-04-24 02:02:39 -04:00
parent 5cec4c8122
commit dc3a6e5793
11 changed files with 2461 additions and 18 deletions

36
src/cmds/roll.ts Normal file
View File

@ -0,0 +1,36 @@
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
import { generateDiscordMessage, safeParseInput } from "../lib/dice";
export const data = new SlashCommandBuilder()
.setName("roll")
.addStringOption(option =>
option.setName("input")
.setDescription("The expression to roll")
.setRequired(true))
.setDescription("Rolls dice using hallowed arc syntax");
export async function execute(interaction: CommandInteraction) {
if (!interaction.isCommand()) return;
const { options } = interaction;
const input = options.get('input', true)?.value as string;
let result = safeParseInput(input);
if (result === null) {
await interaction.reply("Invalid input. Please provide a valid expression.");
return;
}
if (!Array.isArray(result)) {
result = [result];
}
const response = generateDiscordMessage(result);
if (response.length > 2000) {
await interaction.reply("stop that.\n-# (The result is too long to display in a single message. Please try a smaller input.)");
return;
}
await interaction.reply(response);
}