Getting nightbot to tag people but not tag the writer of command if no tag

Hope the title makes sense lol…

So i’ve seen on other channels mods are able to for example type !hours @user which returns @user streamer has 4000 hours in X game, but when typing just !hours on its own it tags no one including not tagging the person that typed the command.

What code would i need to set this up? i know to use !addcom !hours $(touser) streamer has 4000 hours in x game … but doing it this way tags the command typer if no tag is added.

Any help much appreciated, thanks

Use the $(query) variable

https://docs.nightbot.tv/commands/variables/query

!addcom !hours $(query) streamer has 4000 hours in x game

Thanks, the only trouble with that is people can abuse it and make nightbot say things that can’t be moderated … unless its possible to make the $(query) part of the command mod only?

Thanks for the reply though!

Use this:

$(eval d=decodeURIComponent;["owner","moderator"].includes(d("$(querystring $(userlevel))"))?(d("$(querystring)")||" "):" ")

Thanks so much @am_1 i’ll test that out now :slight_smile:

1 Like

i tried editing a test command with it…

!editcom !test $(eval d=decodeURIComponent;[“owner”,“moderator”].includes(d("$(querystring $(userlevel))"))?d("$(querystring)"):" ") test test

and get

[Error Connecting To WebEval Service] test test

Check the post above, the problem is fixed

1 Like

Thanks @am_1 you are a star!!! works perfect now!!!

is it possible to change the query part so it will only ever show the first word after the typed command? just so i can avoid something like !test @user blah blah blah from happening and making nightbot returning the whole sentence rather than just the users tag?

$(eval d=decodeURIComponent;["owner","moderator"].includes(d("$(querystring $(userlevel))"))?(d("$(querystring)").split(" ")[0]||" "):" ")
1 Like

you really are a star, thanks again @am_1 is fool proof now :slight_smile: <3 perfect

1 Like

just did abit of testing with the code and ran into abit of a problem, it made the whole command mod only… really i need the command to be available to all users but the query part of it to be mod only… so any user can still type !test and the command works but only mods can tag users within the nightbot return.

sorry for being a pain!

Looking back to your first message, you want a command called !hours that, when used by a mod with a specified user, goes:

@user Streamer has 4000 hours in X game.

All you have to do is put that message after the $(eval) variable am_1 set up for you:

!addcom -cd=5 !hours $(eval d=decodeURIComponent;["owner","moderator"].includes(d("$(querystring $(userlevel))"))?(d("$(querystring)").split(" ")[0]||" "):" ") Streamer has 4000 hours in X game.

Side note: the -cd=5 part makes the command cooldown 5 seconds. You may either change it to any other value between 5 and 300 or leave it out altogether, in which case it’ll default to 30 seconds.

1 Like

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