I need help with on/off command

I need a command which could kind of “enable” and “disable” other commands, so I tried to do it like this:

!addcom !turn -ul=mod -a=!editcom $(2) -ul=$(eval if($(1)==on){everyone} if($(1)==off){mod})

and when I typed “!turn off !test” it worked like it should be, but if I try to use “!turn on !test” then I get this error message:

" There was an error editing the command. Error: [body.user]Level should be equal to one of the allowed values"

But I’m not sure what i should do to make it work, because i don’t fully understand yet how the eval system works and I’m still kind of new to Nightbot.

(Sorry if i have any errors in my writing)

Hey @Jeii!

I assume you’re using an edited version of Command on/off option - #4 by EmilyPerrimon.

It looks like there has been an update and you now need to be on the same or higher userlevel of the command’s to edit or delete it from the chat, if the command has a higher userlevel than yours it’ll prevent you from doing so, but even working with moderator instead of owner doesn’t fix the issue here… :thinking:

@night when you have a moment do you mind enlightening us?

Yeah I used that since it would have been better version, than the one I was trying to do at first. :slightly_smiling_face:
Do you know what is the issue then, should I be the owner instead of moderator or what? because I’m not 100% sure what is the issue with that command.

And also about this part “if the command has a higher userlevel than yours it’ll prevent you from doing so”
I just let you know, that there is no commands with a higher user level than mine.
Every command have either everyone or moderator user level.

I’m not sure what the issue is here, that’s why I asked the dev about it, just need to be patient for an answer, he’s pretty busy lately.

Just gonna include a screenshot to make it easier on him:

!addcom !turn -ul=mod -a=!editcom $(2) \-ul=$(eval if(`$(1)`==`on`){`everyone`} if(`$(1)`==`off`){`owner`})

It looks like the eval code is causing invalid input. Try the following instead:

!addcom !turn -ul=mod -a=!editcom $(2) \-ul=$(eval `$(1)` === 'on' ? 'everyone' : 'owner')
4 Likes

That’s odd, but thank you, your code is working!

Thank you, it does what it should do :slightly_smiling_face:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.