Advertisement
zTa

discord bot #2 say & ping command

zTa
Sep 11th, 2020
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //server.js//
  2.  
  3. const Discord = require ('discord.js');
  4. const config = require("./config.json"); //make a 'config.json'// crea un archivo 'config.sjon' //
  5. const client = new Discord.Client();
  6.  
  7. client.on('ready', ()=> {
  8.   console.log('bot is ready!');
  9.   client.user.setActivity('Tuto by zTa', {type: 'STREAMING', url:"https://youtube.com/zDrarMc"}).catch
  10. });
  11.  
  12. client.on("message", async message => {
  13.   if(message.author.bot) return;
  14.   if(!message.content.startsWith(config.prefix)) return;
  15.   const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
  16.   const command = args.shift().toLowerCase();
  17.  
  18.   if(command === 'ping'){
  19.   let ping = Math.floor(message.client.ws.ping);
  20.   message.channel.send('➡`' +ping +' ms.` desde su servidor.')
  21.   }
  22.  
  23.   if(command === 'say'){
  24.   const SayCMD = args.join(" "); // lo que introduzcas despues del comando se enviará
  25.     message.delete().catch(O_o=>{}); //bot delete your text// el bot elimina tu mensaje
  26.     message.channel.send(SayCMD); //bot send your text// el bot manda tu mensaje
  27.   }
  28.  
  29. });
  30.  
  31. client.login(config.token);
  32.  
  33.  
  34. //config.json// Crea un archivo config.json
  35.  
  36. {
  37.   "prefix":"!", //use your bot prefix// usa el prefix de tu bot
  38.   "token":"NzQyNzIxNDU4Mjc4NzYwNTA5.XzKPQg.VVH_0dXCLkP1aZUAn8uOaPg564U" //use your bot token// usa el token de tu bot
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement