-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (32 loc) · 1.59 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Require the necessary discord.js classes
const { Client, Intents } = require('discord.js');
const { token } = require('./config.json');
const wait = require('util').promisify(setTimeout);
// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
//Death roll command
if (commandName === 'dr' || commandName === 'roll' || commandName === 'deathroll') {
const num = interaction.options.getInteger('num');
await interaction.reply("💀" +interaction.user.username + " is rolling 1-"+ num +"💀");
await wait(500);
await interaction.editReply("💀" +interaction.user.username + " is rolling 1-"+ num +"💀💀");
await wait(500);
await interaction.editReply("💀" +interaction.user.username + " is rolling 1-"+ num +"💀💀💀");
await wait(500);
//random sometimes goes closer to 0 than 1, but we want to go to 1. add .5 so the lowest we can go is 0.5f, and will round up to 1
var result = (Math.random() * num) + 0.5;
console.log(result);
result = Math.round(result);
console.log(result);
await interaction.editReply((result > 1 ? "🥳 " : "💀 ") + interaction.user.username + " has rolled 1-"+num + " : " + result+" " + (result > 1 ? "🥳" : "💀"));
}
});
// Login to Discord with your client's token
client.login(token);