Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ultirequiem/ultiservant
🌱 UltiUniverse Community Discord Bot
https://github.com/ultirequiem/ultiservant
discord-bot discord-js typescript
Last synced: 3 months ago
JSON representation
🌱 UltiUniverse Community Discord Bot
- Host: GitHub
- URL: https://github.com/ultirequiem/ultiservant
- Owner: UltiRequiem
- License: gpl-3.0
- Created: 2022-03-05T03:04:12.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-19T10:55:53.000Z (over 1 year ago)
- Last Synced: 2024-10-04T18:41:23.363Z (4 months ago)
- Topics: discord-bot, discord-js, typescript
- Language: TypeScript
- Homepage: https://ultirequiem.com/discord
- Size: 155 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# The official UltiUniverse Bot
**join the community**
https://ultirequiem.com/discord
This is the first Discord bot I'm doing, I ever done one using the now dead [discord.py](https://github.com/UltiRequiem/Zetta-Discord-Bot) while learning to code, so I'm just learning on the fly, feel free to make PR or Issues!
## Docs
Things I learned while making this bot 📖
### Commands Handler
People are doing very strange things to handle the commands, here is a simpler
way 👇```ts
import type { CommandInteraction } from "discord.js";import { info, ping, rules } from "./myCommands";
export type command = (interaction: CommandInteraction) => Promise;
export type commandHandler = { [key: string]: command };export const commands: commandHandler = { ping, rules, info };
```Usage 👇
```ts
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return;const { commandName } = interaction;
await commands[commandName](interaction);
});
```Completely type-safe!
> The example in the [docs](https://discordjs.guide/creating-your-bot/command-handling.html#reading-command-files)
> wouldn't work on TypeScript, and would be tricky to make it work using native ESM!## Licence
GNU General Public License v3.0.
[License Resume](https://choosealicense.com/licenses/gpl-3.0)