Created
March 6, 2020 16:34
-
-
Save bmorrisondev/8c6f4ba376c168facef7177c20166da7 to your computer and use it in GitHub Desktop.
A simple Discord bot shell, built using the discord.js library
This file contains hidden or 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'); | |
| 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