Skip to content

Instantly share code, notes, and snippets.

@bmorrisondev
Created March 6, 2020 16:34
Show Gist options
  • Select an option

  • Save bmorrisondev/8c6f4ba376c168facef7177c20166da7 to your computer and use it in GitHub Desktop.

Select an option

Save bmorrisondev/8c6f4ba376c168facef7177c20166da7 to your computer and use it in GitHub Desktop.
A simple Discord bot shell, built using the discord.js library
const Discord = require('discord.js');
const client = new Discord.Client();
// When the bot is ready, log out a message.
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
// When a message is received that starts with 'hello', respond with 'world!'
// This is where you would handle various commands that your bot responds to.
client.on('message', async msg => {
if(msg.content.startsWith("!hello")) {
msg.reply(`world!`)
}
});
// Log out any errors that might occur.
client.on('error', err => {
console.log(err)
});
// This is obtained by registering a bot on https://discordapp.com/developers/applications/
let token = "my-discord-bot-token"
// Start the bot!
client.login(token);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment