Saltar al contenido

Ejemplo de código de guía de Discord.js

Luego de mucho luchar pudimos dar con el resultado de este enigma que tantos usuarios de nuestro espacio han tenido. Si tienes alguna información que aportar no dejes de aportar tu conocimiento.

Ejemplo 1: ejemplo de discord.js

constDiscord=require('discord.js');const client =newDiscord.Client();

client.on('ready',()=>console.log(`Logged in as $client.user.tag!`););

client.on('message',msg=>if(msg.content==='ping')
    msg.reply('Pong!'););

client.login('token');

Ejemplo 2: código de inicio de discord.js

constDiscord=require('discord.js')//this says that its using discord.js and classifing it as a botconst bot =newDiscord.Client();const token ='put your bots token here!';//link to the dev portal to make your own discord bot here: https://discord.com/developers/applications

Ejemplo 3: Conceptos básicos de Discord.js

constDiscord=require("discord.js")const client =newDiscord.Client()
client.on("ready",()=>console.log(`Logged in as $client.user.tag`))
client.on("message",asyncfunction(message)if(message.content==="!test")
	message.reply("Hello World!"))

Ejemplo 4: inicio de discord.js

constDiscord=require('discord.js');const client =newDiscord.Client();const token ='YOUR TOKEN HERE';// For get a token , go here https://discord.com/developers/applications

client.login(token);

Ejemplo 5: descarga de discord.js

/* If you are a mac user, do this in TERMINAL
If you are a Window/Linux user, do this in COMMAND PROMPT

npm install discord.js 

DISCORD.JS IS NOW INSTALLED.
I suggest looking on youtube for a tutorial on setting up a project, but here are the basics.


THIS CODE SHOULD BE IN A "index.js" or "main.js" or whatever your main file is.*/constDiscord=require('discord.js');const client -newDiscord.Client();const/*you can have any prefix you want here*/ prefix ="?"

client.on("ready",()=>console.log('literally anything you want goes here'))//SUPER BASIC COMMAND: BASICALLY SHOWS THAT YOUR BOT CAN SPEAK
client.on('message',message=>if(message.content.startsWith(`$prefixping`))
    	message.channel.send('pong!');)//EXTREMELY IMPORTANT: GET YOUR TOKEN FROM THE DISCORD DEVELOPER PORTAL//NEVER EVER EVER EVER TELL/GIVE ANYONE YOUR TOKEN!
client.login('your token here');

Ejemplo 6: guía de discord.js

// npm install discord.js// Download node.js first if you can't install the discord.js depedenciesconstDiscord=require('discord.js')const client =newDiscord.client()// You can store the prefix in a JSON file and access it // by destructuring it's object propertyconst
  prefix // let's assume it is "!" as the prefix
  token // DO NOT SHARE THAT TO ANYONE IN ANYWAY. You can get that on your Discord bot developer page.=require('./.json')// as an example

client.on("ready",()=>console.log('Ready!'))

client.on("message",message=>// if the message DOES NOT (!) starts with the prefix then the bot will not respondif(!message.content.startsWith(prefix))return;// Here, ping is a template litteral which is an useful way to format declared values with stringsif(message.content===`$prefixping`)// !ping -> bot respond: Pong
    message.channel.send("Pong")

client.login(token)// Your token as stored in a JSON file.

Nos puedes ayudar nuestra investigación fijando un comentario o dejando una valoración te damos la bienvenida.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *