Advertisement
misiekii123

Untitled

May 31st, 2022 (edited)
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. else if (commandName === 'vote') {
  2.         var Accepted = [];
  3.         var Declined = [];
  4.  
  5.         const embed = {
  6.             title: 'vote',
  7.             description: `${interaction.options.getString('treść')}`,
  8.  
  9.             fields: [
  10.                 {
  11.                     name: 'Osoby, które są za:',
  12.                     value: `Czekanie na odpowiedź... `,
  13.                 },
  14.  
  15.                 {
  16.                     name: 'Osoby, które są przeciw:',
  17.                     value: `Czekanie na odpowiedź... `,
  18.                 },
  19.             ],
  20.  
  21.         }
  22.  
  23.         const row = new MessageActionRow()
  24.             .addComponents(
  25.                 new MessageButton()
  26.                     .setCustomId('za')
  27.                     .setLabel('Jestem za')
  28.                     .setStyle('SUCCESS'),
  29.                 new MessageButton()
  30.                     .setCustomId('przeciw')
  31.                     .setLabel('Jestem przeciw')
  32.                     .setStyle('DANGER'),
  33.             );
  34.  
  35.         await interaction.reply({ embeds: [embed], components: [row] });
  36.  
  37.         const collector = interaction.channel.createMessageComponentCollector({ componentType: 'BUTTON', time: 86400000 });
  38.  
  39.         collector.on('collect', i => {
  40.             if (i.customId === 'za') {
  41.                 i.reply({ content: 'Twoja odpowiedź: **Jestem za**', ephemeral: true })
  42.  
  43.                 Accepted.push(`${i.user.username}`)
  44.                 console.log(Accepted)
  45.  
  46.                 const embed = {
  47.                     title: 'vote',
  48.                     description: `${interaction.options.getString('treść')}`,
  49.  
  50.                     fields: [
  51.                         {
  52.                             name: 'Osoby, które są za:',
  53.                             value: `${Accepted}`,
  54.                         },
  55.  
  56.                         {
  57.                             name: 'Osoby, które są przeciw:',
  58.                             value: `${Declined}`,
  59.                         },
  60.                     ],
  61.  
  62.                 }
  63.                 interaction.editReply({ embeds: [embed] });
  64.             }
  65.             else if (i.customId === 'przeciw') {
  66.                 i.reply({ content: 'Twoja odpowiedź: **Jestem przeciw**', ephemeral: true })
  67.  
  68.                 Declined.push(`${i.user.username}`)
  69.  
  70.                 const embed = {
  71.                     title: 'vote',
  72.                     description: `${interaction.options.getString('treść')}`,
  73.  
  74.                     fields: [
  75.                         {
  76.                             name: 'Osoby, które są za:',
  77.                             value: `${Accepted}`,
  78.                         },
  79.  
  80.                         {
  81.                             name: 'Osoby, które są przeciw:',
  82.                             value: `${Declined}`,
  83.                         },
  84.                     ],
  85.  
  86.                 }
  87.                 interaction.editReply({ embeds: [embed] });
  88.             }
  89.         });
  90.  
  91.         collector.on('end', collected => {
  92.             console.log(`Collected ${collected.size} interactions.`);
  93.         });
  94.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement