Last active
January 26, 2025 04:35
-
-
Save pedroricardo/da90fd467962ca8424cfc56dc3a54df6 to your computer and use it in GitHub Desktop.
Como Criar Bot para Discord em Javascript #2 https://www.youtube.com/watch?v=KYnXhtyqQRQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"prefix": "!", | |
"token": "XXXXXXX" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ol