Get data about a command

Asked Aug 10, 2022·1 reply·Last activity 4 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

I'd like to be able to get information about a/the command. Specifically I'm looking to get the userlevel. I see the $(UserLevel) variable but that's for the user, not the command.
As far as I can tell we have no way of giving the user feedback that they're not allowed to execute a command, rather than just being ignored by Nightbot and not getting any useful feedback.

1 reply

Hey @Mild Worm!

You can do what you're looking for by using $(userlevel), here's an example:
→ The command's userlevel is set to Everyone, but you want to limit the output to VIP and above, while displaying an error to the other chatters who don't have the userlevel required:

!addcom !commandName $(eval u=['owner', 'moderator', 'twitch_vip', 'subscriber', 'everyone']; u.indexOf('$(userlevel)') > 2 ? 'You can't use this command, sorry $(user)' : 'You're cool enough to use this command!')

Indexes in arrays start at 0, so twitch_vip is at index 2, update the index number according to your needs.
Update the two responses to your liking.