Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/typicalbot/commands
Minimalistic slash command library for Discord.js
https://github.com/typicalbot/commands
discordjs framework library slash-commands
Last synced: about 2 months ago
JSON representation
Minimalistic slash command library for Discord.js
- Host: GitHub
- URL: https://github.com/typicalbot/commands
- Owner: typicalbot
- License: apache-2.0
- Created: 2021-11-16T20:28:13.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-12T19:14:02.000Z (about 3 years ago)
- Last Synced: 2024-10-12T09:06:19.771Z (3 months ago)
- Topics: discordjs, framework, library, slash-commands
- Language: TypeScript
- Homepage:
- Size: 47.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TypicalBot Commands
Minimalistic slash command library for [Discord.js](https://github.com/discordjs/discord.js).
## Handling Interaction Event
It is recommended that you use [@typicalbot/events](https://github.com/typicalbot/events) with this library. However, we
have provided an example if you choose not to use [@typicalbot/events](https://github.com/typicalbot/events).### TypicalBot Events
```ts
import EventHandler from '@typicalbot/events';const SlashCommandHandler: EventHandler<'interactionCreate'> = async (client, interaction) => {
if (interaction.isCommand()) return;const name = interaction.commandName;
if (client.commands.has(name)) return; // This is a Collection of commandstry {
await client.commands.get(name)?.(client, interaction);
} catch {
await interaction.reply({
content: 'An error occurred while trying to execute that command.'
});
}
}
```### Discord.js
```ts
client.on('interactionCreate', async (interaction) => {
if (interaction.isCommand()) return;const name = interaction.commandName;
if (client.commands.has(name)) return; // This is a Collection of commandstry {
await client.commands.get(name)?.(client, interaction);
} catch {
await interaction.reply({
content: 'An error occurred while trying to execute that command.'
});
}
});
```## License
TypicalBot Commands is an open source software licensed under the [Apache 2.0 license](LICENSE).