2021-11-14 02:18:36 +01:00
|
|
|
const { SlashCommandBuilder, bold } = require('@discordjs/builders');
|
|
|
|
const { MessageEmbed } = require('discord.js');
|
2021-11-09 09:34:55 +01:00
|
|
|
|
2021-11-14 02:18:36 +01:00
|
|
|
const command = new SlashCommandBuilder()
|
2021-11-09 09:34:55 +01:00
|
|
|
.setName('poll')
|
|
|
|
.setDescription('Sondage')
|
|
|
|
.addStringOption(option =>
|
|
|
|
option.setName('question')
|
|
|
|
.setDescription('La question que vous souhaitez poser aux autres utilisateurs')
|
|
|
|
.setRequired(true)
|
2021-11-14 02:18:36 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
for (let i = 0; i<20;i++){
|
|
|
|
var index = i + 1;
|
|
|
|
command.addStringOption(option =>
|
|
|
|
option.setName('réponse' + index )
|
|
|
|
.setDescription('La réponse ' + index)
|
|
|
|
.setRequired(false)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
data: command,
|
2021-11-09 09:34:55 +01:00
|
|
|
async execute(interaction) {
|
|
|
|
const question = interaction.options.get('question').value;
|
2021-11-14 02:18:36 +01:00
|
|
|
const answers = interaction.options.data.slice(1, interaction.options.data.length);
|
|
|
|
const reactions = ['🇦', '🇧', '🇨', '🇩', '🇪', '🇫', '🇬', '🇭', '🇮', '🇯', '🇰', '🇱', '🇲', '🇳', '🇴', '🇵', '🇶', '🇷', '🇸', '🇹', '🇺', '🇻', '🇼', '🇽', '🇾', '🇿' ];
|
|
|
|
var desc = "";
|
|
|
|
var j = 0;
|
|
|
|
answers.forEach(element => {
|
|
|
|
desc += reactions[j] + ' : ' + element.value + '\n';
|
|
|
|
j++;
|
|
|
|
});
|
|
|
|
const embed = new MessageEmbed()
|
|
|
|
.setDescription(desc)
|
|
|
|
.setColor('RANDOM')
|
|
|
|
|
|
|
|
var message = await interaction.reply({content : '📊 ' + bold(question), embeds: [embed], fetchReply: true});
|
|
|
|
j = 0;
|
|
|
|
answers.forEach(element=>{
|
|
|
|
message.react(reactions[j]);
|
|
|
|
j++;
|
|
|
|
})
|
2021-11-09 09:34:55 +01:00
|
|
|
},
|
|
|
|
};
|