Advertisement
Guest User

Discord bot test

a guest
Apr 30th, 2022
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const config = require("./config.json");
  3.  
  4.  
  5. const { MessageAttachment } = require("discord.js");
  6.  
  7. const client = new Discord.Client({
  8. intents: ['GUILD_VOICE_STATES', 'GUILD_MESSAGES', 'GUILDS', 'GUILD_MESSAGE_REACTIONS']
  9. });
  10.  
  11. const prefix = "!";
  12.  
  13. client.on("messageCreate", async function(message) {
  14.  
  15. if (message.author.bot) return;
  16.  
  17. if (!message.content.startsWith(prefix)) return;
  18.  
  19. const commandBody = message.content.slice(prefix.length);
  20.  
  21. const args = commandBody.split(' ');
  22.  
  23. const command = args.shift().toLowerCase();
  24.  
  25.  
  26. if (command === "ping") {
  27.  
  28.  
  29.  
  30. const attachment = new MessageAttachment('https://cdn.mcr.ea.com/3/images/ac394369-2801-4e09-87eb-82ca54e26254/1588018258-0x0-0-0.jpg');
  31. const sentMessage = await message.channel.send({files: [attachment] })
  32. sentMessage.react('👍');
  33. //sentMessage.react('👎');
  34. const filter = (reaction, user) => {
  35. reaction.emoji.name === '👍' && !user.bot;
  36. };
  37. const collector = sentMessage.createReactionCollector({filter, max: 2, time: 15000 });
  38. collector.on('collect', (reaction, user) => {
  39. message.channel.send(`Collected ${reaction.emoji.name} from ${user.tag}`);
  40. });
  41.  
  42. collector.on('end', collected => {
  43. message.channel.send(`Collected ${collected.size} items`);
  44. console.log(`Collected ${collected.size} items`);
  45. });
  46.  
  47.  
  48. }
  49.  
  50.  
  51. });
  52.  
  53. client.login(config.BOT_TOKEN);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement