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 { SlashCommandBuilder, bold } = require('@discordjs/builders');
|
||||||
const { userMention } = require("@discordjs/builders");
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
const command = new SlashCommandBuilder()
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName('poll')
|
.setName('poll')
|
||||||
.setDescription('Sondage')
|
.setDescription('Sondage')
|
||||||
.addStringOption(option =>
|
.addStringOption(option =>
|
||||||
option.setName('question')
|
option.setName('question')
|
||||||
.setDescription('La question que vous souhaitez poser aux autres utilisateurs')
|
.setDescription('La question que vous souhaitez poser aux autres utilisateurs')
|
||||||
.setRequired(true)
|
.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) {
|
async execute(interaction) {
|
||||||
const question = interaction.options.get('question').value;
|
const question = interaction.options.get('question').value;
|
||||||
const textReply = "";
|
const answers = interaction.options.data.slice(1, interaction.options.data.length);
|
||||||
console.log(question);
|
const reactions = ['🇦', '🇧', '🇨', '🇩', '🇪', '🇫', '🇬', '🇭', '🇮', '🇯', '🇰', '🇱', '🇲', '🇳', '🇴', '🇵', '🇶', '🇷', '🇸', '🇹', '🇺', '🇻', '🇼', '🇽', '🇾', '🇿' ];
|
||||||
await interaction.reply('Sondage');
|
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