Giveaway
Giveaways

Create Giveaway

Starts A Giveaway
client.on('message', async message => {
if (message.content.startsWith('!create')) {
const channel = message.mentions.channels.first();
await client.giveaways.startGiveaway({
prize: 'Discord Nitro Classic',
channelId: channel.id,
guildId: message.guild.id,
duration: 30000, // 30 Seconds
winners: 1, // 1 winner
hostedBy: message.author.id
});
}
});

End Giveaway

Ends The Giveaway
client.on('message', async message => {
if (message.content.startsWith('!end')) {
const args = message.content.split(' ').slice(1);
const ended = await client.giveaways.endGiveaway(args.join(' '));
if (!ended) {
return message.channel.send('This giveaway has already ended');
}
else {
message.channel.send('Ended the giveaway');
}
}
});

Reroll Giveaway

Rerolls The GIveaway
client.on('message', async message => {
if (message.content.startsWith('!end')) {
const args = message.content.split(' ').slice(1);
const rerolled = await client.giveaways.rerollGiveaway(args.join(' '));
if (!rerolled) {
return message.channel.send('This giveaway hasn\'t ended');
}
else {
message.channel.send('Rerolled the giveaway');
}
}
});

List Giveaways

Lists The Giveaways Online In The Server
const prettyMilliseconds = require('pretty-ms'); // npm i pretty-ms
​
client.on('message', async message => {
if (message.content.startsWith('!list')) {
const list = await client.giveaways.listGiveaways(message.guild.id);
if (!list) {
return message.channel.send('No active giveaways.');
} else {
message.channel.send(`${list.map(i => `\`${i.messageId}\` - **${i.prize}** | ${prettyMilliseconds(i.timeRemaining)} | Host: **${i.hostedBy}**`).join('\n')}`)
}
}
});
​