randnum
This commit is contained in:
parent
b5dd8c498a
commit
5f4e28f7bc
2 changed files with 48 additions and 0 deletions
7
.idea/prettier.xml
generated
Normal file
7
.idea/prettier.xml
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PrettierConfiguration">
|
||||
<option name="myConfigurationMode" value="AUTOMATIC" />
|
||||
<option name="myRunOnSave" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
41
src/commands/randnum.ts
Normal file
41
src/commands/randnum.ts
Normal 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
|
||||
]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue