Giter Club home page Giter Club logo

discord-bot-starter's Introduction

Discord Bot Starter Project

Introduction

This is a Discord bot starter project made with Discord.js and TypeScript. This template project comes with a simple ping-pong slash command for a predefined guild (server).

Usage

Creating a Discord Application

To create an application that can be registered to a Discord server, you must create a Discord app via the Discord Developer Portal. Once you created an app, you can access the client ID from the General Information setting and the bot token from the Bot setting (see image below).

client-id

bot-token

Configuration

To start the bot server, you must provide the application credentials environmental variables. You can do this by creating a .env file with the following variables.

# Bot user app token
DISCORD_APP_TOKEN=<bot token>
# Bot user client ID
DISCORD_APP_CLIENT_ID=<bot client>
# Server ID for the bot to be installed
DISCORD_GUILD_ID=<guild id>

The DISCORD_GUILD_ID refers to the Discord server ID (or guild ID) that the bot will listen to. You can configure the OAuth2 redirect URL to read and store the guild ID from a remote database when the user add the application to their server for public distribution.

src/config/appConfig.json contains the bot permission, scope, and slash commands. The values must reflect the ones in the Discord Developer Portal app settings.

Scripts

# install all the dependencies
yarn

# starts the server app in node.js environment
yarn start
# or you can use `yarn serve`

# starts a development server with ts-node
yarn dev

# transpile the project for production
yarn build

Quick Start

After running yarn dev, open http://localhost:8080/install to install the application to your Discord server.

Go to a Discord channel that the bot has access to and type /ping.

ping-command

Further Readings

For more information, please refer to the official Discord developer portal or the Discord.js documentation.

discord-bot-starter's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.