A giveaway command but as a slash! Run the command and the bot will choose a random user on your server. You have to go to the slash command builder and create a command called /giveaway whit a string option. That's it. Have fun! Credits: https://autocode.com/sydrazin/snippets/cachsnpt_iq55PvvNXBK7Txh9kURK2S7ZYURaxJhCSL8Q/
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let users = await lib.discord.guilds['@0.1.0'].members.list({
guild_id: `${context.params.event.guild_id}`,
limit: 100,
});
let randomUser = users[Math.floor(Math.random() * users.length)];
console.log(randomUser);
let reason = context.params.event.data.options[0].value;
let channelid = context.params.event.channel_id;
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: context.params.event.channel_id,
content: '🎉Giveaway🎉',
embeds: [
{
type: 'rich',
description: `<@${randomUser.user.id}> you won the **${reason}**`,
color: 0x00ff00,
footer: {
text: `Giveaway hosted by ${context.params.event.member.user.username}#${context.params.event.member.user.discriminator}`,
},
timestamp: `${new Date().toISOString()}`,
},
],
});