Skip to content

Izzxt/discord-ts-handler

Repository files navigation

Discord TS Handler

Getting Started

Prerequisites

  1. Make sure you have nodejs installed.
  • yarn
    npm install -g yarn

Installation

  1. Clone the repo
    git clone https://github.com/your_username_/Project-Name.git
  2. Install packages
    yarn
  3. Rename env.example to .env
  4. Enter your TOKEN, PREFIX, GUILDID, CLIENTID in .env
    TOKEN=your bot token
    PREFIX=
    GUILDID=your guild id
    CLIENTID=your client id

Usage

  • Build
    yarn start:build
  • Start
    yarn start

Register Commands

import { SlashCommandBuilder } from "@discordjs/builders";
import { CommandInteraction } from "discord.js";
import { Bot } from "src/Client";
import { Command } from "../Loaders/Command";

export default class Ping extends Command {

    constructor() {
        super({
            data: new SlashCommandBuilder().setName('ping').setDescription('Send websockets ping in ms')
        })
    }

    public async run(bot: Bot, interaction: CommandInteraction, ...args: any[]): Promise<void> {
        interaction.reply({ content: `Pong! ${bot.ws.ping}`, ephemeral: false })
    }

}

Register Events

import { Event } from "../Loaders/event";
import { Bot } from "../Client";
import { GUILDID } from "../Config";

export default class Ready extends Event {

    constructor() {
        super({ name: 'ready' })
    }

    public async run(bot: Bot): Promise<void> {
        console.log(`Logged in as ${bot.user?.tag}`)
    }

}

Contact

Discord - Izzat#0333

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published