Use o template discord.js para ter seu próprio Bot !!
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 { Client, Intents } = require('discord.js'); | |
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }); | |
// Evento que é executado quando o bot está pronto | |
client.once('ready', () => { | |
console.log(`Logged in as ${client.user.tag}`); | |
}); | |
// Evento que é executado quando o bot recebe uma mensagem | |
client.on('messageCreate', (message) => { | |
// Verifica se a mensagem foi enviada por um bot (para evitar loops infinitos) | |
if (message.author.bot) return; | |
// Verifica se a mensagem começa com "!oi" | |
if (message.content.startsWith('!oi')) { | |
// Responde com uma mensagem | |
message.reply('Oi, como posso ajudar?'); | |
} | |
}); | |
// Conecta o bot ao servidor do Discord usando seu token | |
const BOT_TOKEN = 'SEU_TOKEN_AQUI'; | |
client.login(BOT_TOKEN); |
Try using it before saying anything, okay?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🎉✅