A Discord bot base written in TypeScript.
- Organized command and event handlers.
- Written in minimal code possible.
- Extended Discord client properties.
- Supports the latest Discord.js version (Application commands, ...).
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
To run this project, you will need to add the following environment variables to your .env
file
CLIENT_TOKEN
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;
For support, you can contact me through my email: [email protected]
or either my Discord account: hecker#1234
.
Will be open soon.