Holana/commands/drop.js

66 lines
2 KiB
JavaScript
Raw Permalink Normal View History

2021-10-08 23:58:57 +00:00
const messages = require("../utils/messages");
module.exports = {
description: 'Create a drop giveaway',
options: [
{
2021-10-09 07:31:19 +00:00
name: 'winners',
2021-10-08 23:58:57 +00:00
description: 'How many winners the giveaway should have',
type: 'INTEGER',
required: true
},
{
name: 'prize',
description: 'What the prize of the giveaway should be',
type: 'STRING',
required: true
},
{
name: 'channel',
description: 'The channel to start the giveaway in',
type: 'CHANNEL',
required: true
}
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if(!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")){
return interaction.reply({
content: ':x: You need to have the manage messages permissions to start giveaways.',
ephemeral: true
});
}
2021-10-09 07:31:19 +00:00
2021-10-08 23:58:57 +00:00
const giveawayChannel = interaction.options.getChannel('channel');
const giveawayWinnerCount = interaction.options.getInteger('winners');
const giveawayPrize = interaction.options.getString('prize');
2021-10-09 07:31:19 +00:00
2021-10-08 23:58:57 +00:00
if(!giveawayChannel.isText()) {
return interaction.reply({
2021-10-09 07:31:19 +00:00
content: ':x: Selected channel is not text-based.',
2021-10-08 23:58:57 +00:00
ephemeral: true
});
}
// Start the giveaway
client.giveawaysManager.start(giveawayChannel, {
2021-10-09 07:31:19 +00:00
// The number of winners for this drop
2021-10-08 23:58:57 +00:00
winnerCount: giveawayWinnerCount,
// The prize of the giveaway
prize: giveawayPrize,
// Who hosts this giveaway
hostedBy: client.config.hostedBy ? interaction.user : null,
// specify drop
isDrop: true,
// Messages
messages
});
2021-10-09 07:31:19 +00:00
2021-10-08 23:58:57 +00:00
interaction.reply(`Giveaway started in ${giveawayChannel}!`);
2021-10-09 07:31:19 +00:00
2021-10-08 23:58:57 +00:00
}
2021-10-09 07:31:19 +00:00
};