Skip to content

ikasoba/distroub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@ikasoba000/distroub

Utilities for creating bots in discord.js

npm npm type definitions

example

import { Client, ChatInputCommandInteraction as Interaction } from "discord.js";
import {
  DiscordBot,
  SlashCommand,
  Param,
  ParamType,
} from "@ikasoba000/distroub";

const client = new Client( ... );

class MyBot extends DiscordBot {
  constructor(client: Client) {
    super(client);
  }

  @ClientEvent("ready")
  onReady(){
    console.info("Bot activated, bot user: ", this.client.user?.tag);
  }

  // Create /random command
  @SlashCommand("random", "take a random number", [
    Param(ParamType("number").optional(), "max", "Upper limit of random number"),
  ])
  async getRandomNumber(interaction: Interaction, max?: number) {
    max ??= 10;

    await interaction.deferReply();
    await interaction.editReply("" + Math.floor(Math.random() * max));
  }
}

const bot = new MyBot(client);

await bot.login( ... );

About

utility for discord.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published