Advertisement
ala89

TUTO DEV #15 - CREER UN BOT DISCORD : POLL ET 8BALL

Nov 4th, 2020
4,728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // poll.js
  2. const Discord = require('discord.js'),
  3.     reactions = ['๐Ÿ‡ฆ', '๐Ÿ‡ง', '๐Ÿ‡จ', '๐Ÿ‡ฉ', '๐Ÿ‡ช', '๐Ÿ‡ซ', '๐Ÿ‡ฌ', '๐Ÿ‡ญ', '๐Ÿ‡ฎ', '๐Ÿ‡ฏ', '๐Ÿ‡ฐ', '๐Ÿ‡ฑ', '๐Ÿ‡ฒ', '๐Ÿ‡ณ', '๐Ÿ‡ด', '๐Ÿ‡ต', '๐Ÿ‡ถ', '๐Ÿ‡ท', '๐Ÿ‡ธ', '๐Ÿ‡น']
  4.  
  5. module.exports = {
  6.     run: async (message, args) => {
  7.         if (!message.member.hasPermission('MANAGE_GUILD')) return message.channel.send('Vous n\'avez pas la permission d\'utiliser cette commande.')
  8.         const [question, ...choices] = args.join(' ').split(' | ')
  9.         if (!question) return message.channel.send('Veuillez indiquer la question ร  poser.')
  10.         if (!choices.length) return message.channel.send('Veuillez indiquer au moins 1 choix.')
  11.         if (choices.length > 20) return message.channel.send('Il ne peut pas y avoir plus de 20 choix.')
  12.         message.delete()
  13.         const sent = await message.channel.send(new Discord.MessageEmbed()
  14.             .setTitle(question)
  15.             .setDescription(choices.map((choice, i) => `${reactions[i]} ${choice}`).join('\n\n')))
  16.         for (i = 0; i < choices.length; i++) await sent.react(reactions[i])
  17.     },
  18.     name: 'poll',
  19.     guildOnly: true
  20. }
  21.  
  22. // 8ball.js
  23. const Discord = require('discord.js'),
  24.     replies = ['Oui', 'Non', 'Peut รชtre', 'Evidemment']
  25.  
  26. module.exports = {
  27.     run: (message, args) => {
  28.         const question = args.join(' ')
  29.         if (!question) return message.channel.send('Veuillez indiquer une question.')
  30.         message.channel.send(new Discord.MessageEmbed()
  31.             .setTitle(question)
  32.             .setDescription(replies[Math.floor(Math.random() * replies.length)]))
  33.     },
  34.     name: '8ball'
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement