This commit is contained in:
amy 2025-04-30 23:10:04 +03:30
parent b5dd8c498a
commit 5f4e28f7bc
No known key found for this signature in database
2 changed files with 48 additions and 0 deletions

41
src/commands/randnum.ts Normal file
View file

@ -0,0 +1,41 @@
import {Command} from "../command.ts";
import {
ApplicationIntegrationType,
ChatInputCommandInteraction,
InteractionContextType,
SlashCommandBuilder
} from "discord.js";
import { type Config } from "../config.ts";
export default class PingCommand extends Command {
async run(interaction: ChatInputCommandInteraction, config: Config) {
const upperbound = interaction.options.getInteger("upperbound")!;
const comment = interaction.options.getString("comment");
if (comment === null){
await interaction.reply({
content: "random number is: " + `${Math.floor(Math.random() * upperbound)}`,
});
return
}
await interaction.reply({
content: `chances of ${comment} out of ${upperbound} is ${Math.floor(Math.random() * upperbound)}`,
});
}
slashCommand = new SlashCommandBuilder()
.setName("randnum")
.setDescription("random number").setIntegrationTypes([
ApplicationIntegrationType.UserInstall
]).addIntegerOption(option => {
return option.setName("upperbound").setRequired(true).setDescription("idk nea told me")
}).addStringOption(option => {
return option.setName("comment").setRequired(false).setDescription("comment")
})
.setContexts([
InteractionContextType.BotDM,
InteractionContextType.Guild,
InteractionContextType.PrivateChannel
]);
}