Advertisement
Guest User

First Discord Bot

a guest
Aug 21st, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. // Calling the package
  2. var Discord = require('discord.js');
  3. var bot = new Discord.Client();
  4.  
  5. // Listener Event: Message Received ( This will run every time a message is received )
  6. bot.on('message', message => {
  7.  
  8. // Variables
  9. var sender = message.author; // The person who sent the message.
  10. var msg = message.content.toLowerCase(); // Takes the message, and makes it all lowercase.
  11. var prefix = '>' // The prefix of the bot, you can set this to what ever you want.
  12.  
  13. // Greetings messages
  14. if (msg === prefix + 'vep') {
  15. message.channel.send('Welcome to Relax server') // Sends a message to the channel, with the contents: "sksksk welcome to R E L A X"
  16. }
  17.  
  18.  
  19. // More Greeting Messages
  20. if (msg === prefix + 'reto') {
  21. message.channel.send('We hope you have fun here sksksk')
  22.  
  23. }
  24.  
  25.  
  26. // More Greeting messages
  27. if (msg === prefix + 'tee') {
  28. message.channel.send('Everyone is welcomed here')
  29.  
  30. }
  31.  
  32. // Deleting Specific Messages ( Messages that are not an ID for me )
  33. if (message.channel.id === '613805872396763249') { // Checks if the message is in the specific channel
  34. if (isNaN(message.content)) { // Checks if the message is not a number, if it's not the following code will run
  35. message.delete() // This deletes the message
  36. message.author.send('Only post numbers in <#613805872396763249> channel please. Thank you!') // This private messages the author that what they posted was invalid.
  37. }
  38. }
  39. })
  40.  
  41. // Listener Event: Bot Launched
  42. bot.on('ready', () => {
  43. console.log('Bot Launched...') // Runs when the bot is Launched
  44.  
  45. // You can put any code you want here, it will run when your turn on your bot.
  46.  
  47. });
  48.  
  49. // Login
  50. bot.login('NjEzODIxNjg0NDc0MDUyNjY1.XV2gGQ.v2IoiDUlLErob-udjefIOPm4kjI') // Don't let people see this code, people can control yor bot, including the servers your bot has admin in.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement