Giter VIP home page Giter VIP logo

ts-discord-bot-base's Introduction

Logo

Discord bot base - Writte in TypeScript

A Discord bot base written in TypeScript.

Features

  • Organized command and event handlers.
  • Written in minimal code possible.
  • Extended Discord client properties.
  • Supports the latest Discord.js version (Application commands, ...).

Run Locally

Clone the project

  git clone https://github.com/HirboSH/ts-discord-bot-base

Go to the project directory

  cd ts-discord-bot-base

Install dependencies

  npm install

Start the server

  npm run dev

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

CLIENT_TOKEN

Usage / Examples

Here's an example of creating a new slash command, (Under commands folder).

import type { ExtendedClient, CommandInteractionWithGuildMember } from "../interfaces/Interfaces";

export default {
    name: "test",
    description: "Testing command.",
    type: 'CHAT_INPUT',
    options: [],

    run: async (client: ExtendedClient, interaction: CommandInteractionWithGuildMember, args: any) => {
        return await interaction.reply({ content: "Hello World!", ephemeral: true }).catch(e => console.log(e));
    }
};

In case you'll want to add args to the command, simply just specify those inside options: [] in this format:

{
    name: ArgName,
    type: ApplicationCommandOptionType, // See https://discordjs.guide/interactions/slash-commands.html#options
    description: string,
    required: bool
}

Here's an example of creating a new event callback, (Under events folder).
This callback uses the same params as the event gives.

import type { ExtendedClient } from "../interfaces/ExtendedClient";

async function ready(client: ExtendedClient) {
    console.log(`Logged in as: ${client?.user?.tag}`);

    client.user?.setPresence({ activities: [{ name: 'Visual Studio Code' }], status: 'idle' });
    
    await client.application?.commands.set(client.commandsArr);
};

export default ready;

Support

For support, you can contact me through my email: [email protected] or either my Discord account: hecker#1234.

Contributing

Will be open soon.

Acknowledgements

Authors

ts-discord-bot-base's People

Contributors

fsocietystudios avatar

Stargazers

Tjay avatar Benito "DK_Den7e" L. avatar

Watchers

 avatar

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.