Have some places in mind but can't decide where to go? Or having a massive selection of cheesecakes but don't know which to eat? Then you came to the right place my friend, this amazing snippet can decide for you with a ease, just give a list of things and your bot will randomly pick one for you! Example on how to use: " >pick cinema, shopping mall, cafe "
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let sleep = async (ms) => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
};
let names = context.params.event.content.split(' ').splice(1).join(' ').split(' ');
let random = names[Math.floor(Math.random() * names.length)].replace(',' ,'')
// you can chage ">pick" to anything you like! but do it for all the ">pick" so you don't break the code!
if (context.params.event.content.startsWith('>pick') && !names[1]){
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Please give me more then two options to pick from!`
})
} else if
(context.params.event.content.startsWith('>pick')){
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: 'I choose... *`Drumroll effect`*'
})
// you can change the "sleep" time, the time is calculated in milliseconds, so 5 seconds is 5000 milliseconds.
await sleep(3000);
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `**${random}!**`
})
}
//Example on how to use: " >pick cinema, shopping mall, cafe"
//NOTE: You don't have to use a comma, it works either way.
// Credit to Notedwin and Meiraba for helping me (~UwU~)