this starts a loading message, it starts rolling the dice before it successfully gives the die number! this doesnt require a number to role, you just have to change your prefix and runn the command.
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let event = context.params.event;
let sleep = async (ms) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, ms || 0);
});
};
let die = [1, 2, 3, 4, 5, 6];
let randomdie = die[Math.floor(Math.random() * die.length)];
let message = [
`π² | Aww it's a ${randomdie}`,
`π² | oh no it's a ${randomdie}`,
`π² | oh my it's a ${randomdie}`,
];
let FinalMess = message[Math.floor(Math.random() * message.length)];
let cooldown = await lib.utils.kv['@0.1.16'].get({
key: `cooldown_${event.author.id}`,
});
if (cooldown) {
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: event.channel_id,
content: `You have to wait for 30 seconds before searching again!`,
});
} else {
await lib.utils.kv['@0.1.16'].set({
key: `cooldown_${event.author.id}`,
value: event.author.id,
ttl: 30,
});
let rolldie = await lib.discord.channels['@0.0.6'].messages.create({
channel_id: context.params.event.channel_id,
content: `<@${context.params.event.author.id}> is rolling a π² 6-sides die.... `,
});
await sleep(1500);
await lib.discord.channels['@0.3.0'].messages.update({
message_id: rolldie.id,
channel_id: event.channel_id,
content: `please wait a second....`,
});
await sleep(1500);
await lib.discord.channels['@0.3.0'].messages.update({
message_id: rolldie.id,
channel_id: event.channel_id,
content: `laying the dice...`,
});
await sleep(1000);
await lib.discord.channels['@0.3.0'].messages.update({
message_id: rolldie.id,
channel_id: event.channel_id,
content: FinalMess,
});
}