Giveaway
Giveaways

Create Giveaway

Starts A Giveaway
1
client.on('message', async message => {
2
if (message.content.startsWith('!create')) {
3
const channel = message.mentions.channels.first();
4
await client.giveaways.startGiveaway({
5
prize: 'Discord Nitro Classic',
6
channelId: channel.id,
7
guildId: message.guild.id,
8
duration: 30000, // 30 Seconds
9
winners: 1, // 1 winner
10
hostedBy: message.author.id
11
});
12
}
13
});
Copied!

End Giveaway

Ends The Giveaway
1
client.on('message', async message => {
2
if (message.content.startsWith('!end')) {
3
const args = message.content.split(' ').slice(1);
4
const ended = await client.giveaways.endGiveaway(args.join(' '));
5
6
if (!ended) {
7
return message.channel.send('This giveaway has already ended');
8
}
9
else {
10
message.channel.send('Ended the giveaway');
11
}
12
}
13
});
Copied!

Reroll Giveaway

Rerolls The GIveaway
1
client.on('message', async message => {
2
if (message.content.startsWith('!end')) {
3
const args = message.content.split(' ').slice(1);
4
const rerolled = await client.giveaways.rerollGiveaway(args.join(' '));
5
6
if (!rerolled) {
7
return message.channel.send('This giveaway hasn\'t ended');
8
}
9
else {
10
message.channel.send('Rerolled the giveaway');
11
}
12
}
13
});
Copied!

List Giveaways

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