Skip to content

fsocietystudios/ts-discord-bot-base

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

My Discord bot base written in Typescript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published