Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikasoba/distroub
utility for discord.js
https://github.com/ikasoba/distroub
Last synced: 15 days ago
JSON representation
utility for discord.js
- Host: GitHub
- URL: https://github.com/ikasoba/distroub
- Owner: ikasoba
- Created: 2023-05-24T09:35:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-25T13:32:53.000Z (over 1 year ago)
- Last Synced: 2024-11-24T03:08:26.696Z (about 1 month ago)
- Language: TypeScript
- Size: 76.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
@ikasoba000/distroub
Utilities for creating bots in discord.js
# example
```ts
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( ... );
```