ajout de la fonctionnalité de sondage
This commit is contained in:
parent
af2d70e2cb
commit
1ef53e8dd0
@ -1,19 +1,45 @@
|
||||
const { SlashCommandBuilder, codeBlock } = require('@discordjs/builders');
|
||||
const { userMention } = require("@discordjs/builders");
|
||||
const { SlashCommandBuilder, bold } = require('@discordjs/builders');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
const command = new SlashCommandBuilder()
|
||||
.setName('poll')
|
||||
.setDescription('Sondage')
|
||||
.addStringOption(option =>
|
||||
option.setName('question')
|
||||
.setDescription('La question que vous souhaitez poser aux autres utilisateurs')
|
||||
.setRequired(true)
|
||||
),
|
||||
);
|
||||
|
||||
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,
|
||||
async execute(interaction) {
|
||||
const question = interaction.options.get('question').value;
|
||||
const textReply = "";
|
||||
console.log(question);
|
||||
await interaction.reply('Sondage');
|
||||
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++;
|
||||
})
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user