joeyk710 / sample-discordjs-bot

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.
GNU General Public License v3.0
15 stars 3 forks source link
discord-api discord-bot discordjs typescript-discord-bot

Sample TypeScript Discord Bot πŸ€–

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.

npm version

Features include (not limited to):

[!IMPORTANT] Most current or LTS version Node.js is required!

Node.js

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.
    
    APPLICATION_ID=
    # Your bot's application ID (can be found on Discord or on the Discord Developer Portal)
  4. Installing dependencies

    pnpm install
  5. Deploying Commands

    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

    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