Skip to content
This repository has been archived by the owner on Dec 24, 2021. It is now read-only.

Emit disabledCommandRun when running a disabled command #378

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Emit disabledCommandRun when running a disabled command #378

wants to merge 2 commits into from

Conversation

cocoliliace
Copy link

Resolved #336

src/dispatcher.js Outdated Show resolved Hide resolved
@cocoliliace
Copy link
Author

cocoliliace commented Feb 23, 2021

I noticed that disabled commands are checked in dispatcher.js while the rest of commandBlock events (nsfw, guildOnly, permission... etc.) are checked in message.run(). Should I move disabled commands to message.run() to make it consistent?
Instead of emitting disabledCommandRun maybe we should emit commandBlock with an argument of disabled

@Gawdl3y
Copy link
Member

Gawdl3y commented Mar 28, 2021

The idea behind a command being disabled is to prevent any additional processing for it, so nothing in the command's code is run at all. Off the top of my head, moving the handling for this to CommandMessage#run would mean that it occurs after parsing arguments and such.

@cocoliliace
Copy link
Author

It looks like the conditions are checked at the beginning of CommandMessage#run, right before parsing the arguments, so I think CommandMessage#run would still be able to return early upon detecting the disabled command.
Currently, the check for whether a command is disabled happens on an if statement in CommandDispatcher#handleMessage, and CommandMessage#run is called in the corresponding else if branch. If we remove the if statement there, CommandMessage#run would be called and the disabled commands would be immediately handled at the top of CommandMessage#run, which is also where gulidOnly, nsfw, and permissions are checked.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client event for running disabled commands
4 participants