I need help to create this command

Asked Dec 6, 2020·2 replies·Last activity 5 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.

Hello, first i'm sorry if there are errors in my writing, I do not have a very good English. I am trying to create a command called ''!report''. The idea of this command is only to be fun for users. The command is supposed to work in this way:

User: !report @member* use the pacman (:v)*

and bot reply...

Nighbot: The user @member* has been reported for ''use the pacman (:v)''.*

My problem is that I can’t use argument variables $(1-9), as the idea is that the user’s ''reason'' is unlimited words. Nor can I use $(query) as this repeats exactly what the user says and i could not customize the bot response. Is there a way to do this with a customapi or something?

2 replies

The following javascript code puts the arguments in an array "args". It can also be used to have a custom seperator (if you don't want to split at each space but at each colon for instance, juste replace \ \ with \:\ in split).

javascript
$(eval
args=decodeURIComponent(`$(querystring)`).split(` `);
// then do your stuff
)

Hey @Tiny Cat!

Following on the answer of @Cosmic Elephant, here's how you'd make your command:

$(eval q=decodeURIComponent(`$(querystring)`).split(` `); u=q.shift().replace(`@`,``); `The user ${u} has been reported for "${q.join(` `)}."`)