Learn to create, deploy, and manage bots for Project123456 communities.
const { Client, IntentsBitField } = require('discord.js');
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent
]
});
client.login('YOUR_BOT_TOKEN');
client.on('messageCreate', message => {
if (message.content.startsWith('!ping')) {
message.reply('Pong! 🏓');
}
});
Use the Discord API to register slash commands globally or in specific guilds.
/client.commands = new Collection(); client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; const command = client.commands.get(interaction.commandName); if (!command) return; try { await command.execute(interaction); } catch (error) { console.error(error); await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); } });
Store bot data using MongoDB, PostgreSQL, or in-memory caches for persistent storage.
View Database GuideJoin thousands of developers creating innovative bots for servers across Project123456.