initial
This commit is contained in:
43
commands/howlucky.js
Normal file
43
commands/howlucky.js
Normal file
@ -0,0 +1,43 @@
|
||||
const { SlashCommandBuilder, SlashCommandNumberOption } = require("discord.js");
|
||||
|
||||
let tries = (module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName("howlucky")
|
||||
.setDescription("How lucky are you?")
|
||||
.addNumberOption(
|
||||
new SlashCommandNumberOption()
|
||||
.setName("tries")
|
||||
.setDescription("how many tries you have")
|
||||
.setRequired(true)
|
||||
.setMinValue(1)
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("probability")
|
||||
.setDescription("you can guess")
|
||||
.setRequired(true)
|
||||
),
|
||||
async execute(interaction) {
|
||||
let probabilitylowernum;
|
||||
if (interaction.options.getString("probability").split("/")[1] == null) {
|
||||
probabilitylowernum = parseInt(
|
||||
interaction.options.getString("probability")
|
||||
);
|
||||
} else {
|
||||
probabilitylowernum = parseInt(
|
||||
interaction.options.getString("probability").split("/")[1]
|
||||
);
|
||||
}
|
||||
let result =
|
||||
(interaction.options.getNumber("tries") / probabilitylowernum) * 100;
|
||||
await interaction.reply(
|
||||
`With a drop chance of ${interaction.options.getString(
|
||||
"probability"
|
||||
)}, getting a drop within ${interaction.options.getNumber(
|
||||
"tries"
|
||||
)} tries has a **${
|
||||
Math.round(result * 100) / 100
|
||||
}%** chance of happening.`
|
||||
);
|
||||
},
|
||||
});
|
Reference in New Issue
Block a user