Error with options
const {
EmbedBuilder,
ApplicationCommandType } =
require ("discord.js")
const ms = require("ms")
module.exports = {
name: "start",
description: "Permet de lancer un giveaway",
type: ApplicationCommandType.ChatInput,
options: [{
name: "temps",
description: "Exemple : 1m, 1h, 1d",
type: 3,
required: true
},{
name: "Cadeau",
description: "Le prix du gagnant",
type: 3,
required: true
},{
name: "winners",
description: "Nombre de gagnant",
type: 6,
required: true
},{
name: "Salon",
description: "Le salon du giveaway",
type: 4,
required: true
}],
execute: async(client, interaction) => {
let time = interaction.options.getString("temps")
let cadeau = interaction.options.getString("cadeau")
let salon = interaction.options.getChannel("Salon")
let winners = interaction.options.getInteger("winners")
if (!salon.isTextBased()) {
return interaction.reply({
content: '**Veuillez choisir un salon textuel valide**',
ephemeral: true
});
}
if(isNaN(ms(time))) {
return interaction.reply({
content: '**Veuillez déterminer un temps valide. Exemple : 1m, 1h, 1d**',
ephemeral: true
});
}
if (winners < 1) {
return interaction.reply({
content: '**Veuillez déterminer un nombre de gagnant supérieur a 0**',
})
}
client.giveawaysManager.start(salon, {
duration: ms(time),
prize: cadeau,
winnerCount: parseInt(winners),
hostedBy: interaction.user
})
const s = new EmbedBuilder()
.setTitle(`**Giveaways lancer dans le salon ${salon}**`)
.setColor("#e91e61")
interaction.reply({embeds: [s]})
}
}
const {
EmbedBuilder,
ApplicationCommandType } =
require ("discord.js")
const ms = require("ms")
module.exports = {
name: "start",
description: "Permet de lancer un giveaway",
type: ApplicationCommandType.ChatInput,
options: [{
name: "temps",
description: "Exemple : 1m, 1h, 1d",
type: 3,
required: true
},{
name: "Cadeau",
description: "Le prix du gagnant",
type: 3,
required: true
},{
name: "winners",
description: "Nombre de gagnant",
type: 6,
required: true
},{
name: "Salon",
description: "Le salon du giveaway",
type: 4,
required: true
}],
execute: async(client, interaction) => {
let time = interaction.options.getString("temps")
let cadeau = interaction.options.getString("cadeau")
let salon = interaction.options.getChannel("Salon")
let winners = interaction.options.getInteger("winners")
if (!salon.isTextBased()) {
return interaction.reply({
content: '**Veuillez choisir un salon textuel valide**',
ephemeral: true
});
}
if(isNaN(ms(time))) {
return interaction.reply({
content: '**Veuillez déterminer un temps valide. Exemple : 1m, 1h, 1d**',
ephemeral: true
});
}
if (winners < 1) {
return interaction.reply({
content: '**Veuillez déterminer un nombre de gagnant supérieur a 0**',
})
}
client.giveawaysManager.start(salon, {
duration: ms(time),
prize: cadeau,
winnerCount: parseInt(winners),
hostedBy: interaction.user
})
const s = new EmbedBuilder()
.setTitle(`**Giveaways lancer dans le salon ${salon}**`)
.setColor("#e91e61")
interaction.reply({embeds: [s]})
}
}
3 Replies