Skip to content

This is a sample discord bot made with TypeScript, using discord.js. Uses examples from the discord.js guide - https://discordjs.guide/ with a handler that supports command categories.

License

Notifications You must be signed in to change notification settings

joeyk710/sample-discordjs-bot

Repository files navigation

About

This sample Discord bot written in TypeScript is a great starting place for creating the bot of your ✨ dreams ✨.

Primarily using discord.js with examples used from the discord.js guide.

Features include (but not limited to):

  • Command & Event handlers
  • Starter Slash & Context-Menu Commands
  • Optional per-command cooldowns & User / Client permission checking

Important

Most current Node LTS (Long-Term Support) Version is required

Getting Started 🎉

  1. Clone the repository here on Github or from terminal (shown below)

    git clone https://github.com/joeyk710/sample-discordjs-bot.git
    cd sample-discordjs-bot
  2. Rename .env.example to .env

  3. Open the .env file and fill in the required values as shown below

    DISCORD_TOKEN= 
    # Your bot token
    
    GUILD_ID=
    # Only put an ID here if you want commands to be registered in one server.
    
    CLIENT_ID=
    # Your bot's application ID (can be found on Discord or on the Discord Developer Portal)
  4. Installing dependencies

    npm install
    yarn install
    pnpm install
  5. Deploying Commands

    npm run deploy
    yarn run deploy
    pnpm run deploy

Note

If there is no GUILD_ID in the .env file, commands will be registered globally.

Only run this terminal script if you need to add commands or edit command data that do not appear in your server.

  1. Starting the bot

    npm run start
    yarn run start
    pnpm run start

Sample Commands 🤖

Name Description
/ping Responds with "Pong!"
Echo Echoes the message selected in the channel the command was sent in

Note

Please check the discord.js docs, discord.js guide, and discord-api-types for proper types, properties and method usage.

You will notice the current discord.js guide uses @discordjs/builders for command creation. This template uses raw objects for creating commands which makes use of enum types ApplicationCommandType and ApplicationCommandOptionType.

⚠️ This template assumes you have a general understanding of TypeScript ⚠️

Issues 💭

If you have any problems, please don't hesitate to open an issue here.

Contributing 🙌

Contributions are welcome! Please don't hesitate to open a pull request here.

License 🪪

This project is licensed under the GNU General Public License v3.0 - see the LICENSE.md file for details

About

This is a sample discord bot made with TypeScript, using discord.js. Uses examples from the discord.js guide - https://discordjs.guide/ with a handler that supports command categories.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published