Giter VIP home page Giter VIP logo

discord-bot-starter-ts's Introduction

Discord Bot Starter ⚡ (TypeScript Edition)

This is a TypeScript template for creating Discord bots using the discord.js library. This repo provides a robust foundation, packed with useful features to jumpstart your bot development.

How to use

  1. Clone or download this repository
  2. Run npm install to install the required packages
  3. Rename .env.example to .env and fill in
  4. Run npm run dev to start the bot in development mode
  5. Write your bot logic in the src folder

Scripts

Development mode

npm run dev

Starts the bot using ts-node-dev, which auto-restarts on code changes.

Production mode

npm start

Compiles TypeScript to JavaScript and starts the bot using ts-node.

Features

Command handler

This flexible system lets you manage your bot's commands effortlessly. Create new commands by following a simple structure:

// src/commands/example.ts
export default class ExampleCommand extends Command {
  constructor(client: CustomClient) {
    super(client, {
      name: CommandName.Example,
      description: "Demonstrates command creation.",
      category: CommandCategory.General,
    });
  }

  async execute(interaction: ChatInputCommandInteraction): Promise<void> {
    await interaction.reply("Hello from the command handler!");
  }
}

Subfolders and organization: Organize your commands logically using subfolders based on their categories (e.g., src/commands/moderation/ban.ts). Remember to update the types.ts file with new command names and categories.

Slash commands

You can create slash command options by using this.data property. For example, this is how you can add a String option:

super(client, {
  // ...
});

// Creating slash command options
this.data.addStringOption((option) =>
  option
    .setName("input")
    .setDescription("The input to echo back")
    .setRequired(true)
);

discord-bot-starter-ts's People

Contributors

alexinhans avatar meenic avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

meenic

discord-bot-starter-ts's Issues

Improve documentation

The latest readme file represents the old version, so an updated version of the docs is required.

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.