0.5.1 • Published 2 years ago

@typicalbot/commands v0.5.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

TypicalBot Commands

Minimalistic slash command library for Discord.js.

Handling Interaction Event

It is recommended that you use @typicalbot/events with this library. However, we have provided an example if you choose not to use @typicalbot/events.

TypicalBot Events

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 commands

    try {
        await client.commands.get(name)?.(client, interaction);
    } catch {
        await interaction.reply({
            content: 'An error occurred while trying to execute that command.'
        });
    }
}

Discord.js

client.on('interactionCreate', async (interaction) => {
    if (interaction.isCommand()) return;

    const name = interaction.commandName;
    if (client.commands.has(name)) return; // This is a Collection of commands

    try {
        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.

0.5.1

2 years ago

0.5.0

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago