Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KendiHashimoto/5080631aad663ccaea0754c38b802521 to your computer and use it in GitHub Desktop.
Save KendiHashimoto/5080631aad663ccaea0754c38b802521 to your computer and use it in GitHub Desktop.
Como Criar Bot para Discord em Javascript #2 https://www.youtube.com/watch?v=KYnXhtyqQRQ
const Discord = require("discord.js"); //baixar a lib
const client = new Discord.Client();
const config = require("./config.json");
client.on("ready", () => {
console.log(`Bot foi iniciado, com ${client.users.size} usuários, em ${client.channels.size} canais, em ${client.guilds.size} servidores.`);
client.user.setPresence({ game: { name: 'comando', type: 1, url: 'https://www.twitch.tv/pedroricardo'} });
//0 = Jogando
// 1 = Transmitindo
// 2 = Ouvindo
// 3 = Assistindo
});
client.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
if(!message.content.startsWith(config.prefix)) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
const comando = args.shift().toLowerCase();
// coamdno ping
if(comando === "ping") {
const m = await message.channel.send("Ping?");
m.edit(`Pong! A Latência é ${m.createdTimestamp - message.createdTimestamp}ms. A Latencia da API é ${Math.round(client.ping)}ms`);
}
});
client.login(config.token);
{
"prefix": "!",
"token": "XXXXXXX"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment