Skip to content

Command handler decorators

Latest
Compare
Choose a tag to compare
@Mimickal Mimickal released this 23 Sep 21:49
efbc597

Note: v3.1.0 does not exist because I unpublished it after a bout of temporary insanity working directly off master

Added requireAdmin and requireGuild decorators that can wrap command handlers with common logic.

In the following example, using requireGuild allows the handler to skip checking if the interaction is happening in a guild.

const { requireGuild, SlashCommandBuilder } = require('discord-command-registry');

const cmd = new SlashCommandBuilder().setHandler(requireGuild(cmdHandler));

// interaction.guild is now guaranteed to not be null
function cmdHandler(interaction) {
    interaction.guild; // Not null!
}