There are different ways to make a slap command, but I would like to make commands in the quote system using templates with the choice of querystring or random user
how it should look
templates quote system
but constantly getting
$(user) is not defined // in this case QZMTCH is not defined
the question is, can two fetch requests be used in one eval?
is it possible to somehow make it so that it is possible to use random messages perhaps even sometimes without a user where instead of a user there would be a nightbot?
help solve this problem
Why exactly use the quote system? You don’t need it for a simple slap command like the one you’re thinking about, it’s pretty much a waste of resources. There is much more simple:
yes, but then you can’t make teams with different texts, with different actions, such as where instead of the user there is a nightbot, or when randUser did something to the user
Ok, I see what you want to do now, then I think using Pastebin would still be a better solution. Create an account and make a private paste that won’t expire.
And the paste will look like this for example:
r=Math.floor(Math.random()*3);
if(r==0){
`${q}`?`${u} slaps ${q}`:`${u} slaps ${t}`;}
else if(r==1){
`${t} dodged a slap from ${u}`;}
else if(r==2){
t==`nightbot`?`Get out of here, Nightbot!`:`Welcome in ${t}`;}
then I want to customize the command so that you can use querystring, and maybe the second argument, such as
!slap nick nick
the first argument will be the one who slaps, and the second one who gets
If someone else can improve the code that I wrote above with a quotation system or pastebin (which never worked for me), please write in the comments, I would really like to see the implementation of these features, from those who know how to write this or that code in short.
Thanks to all
PS one more request, I looked at the forum a few topics about pastebin, one more request, I looked at the forum on several topics about pastebin, and I would like from those who know more than me how to use pastebin to extend the code, it just came up with the idea of making more replaceable variables in the template quote system, besides %user %randUser add %rand (randomNumber) etc
if possible, then write in the answer how to do it correctly, without errors
thanks in advance
Sorry for the trouble, got a couple of busy days and I didn’t have time to test the command I was giving you, $(urlfetch) can be a bit of a pain sometimes, my bad, anyway, here’s the solutiom, I tested it this time, and this will answer your question on how to extend code with a Pastebin as well.
r=Math.floor(Math.random()*3);
if(r==0){
`${q}`?`${u} slaps ${q}`:`${u} slaps ${t}`;}
else if(r==1){
`${t} dodged a slap from ${u}`;}
else if(r==2){
t==`nightbot`?`Get out of here, Nightbot!`:`Welcome in ${t}`;}
Notice how I declare every variables I use in the paste before using $(urlfetch) to call the paste, I do it this way because Nightbot doesn’t replace variables such as $(user) if the code comes from the paste.
The idea behind the code in the paste is that since I have 3 different possible responses, I generate a random number between 0 and 2 and then from there I select which response Nightbot will give.
And regarding your question with having two arguments, you can do it like so:
there is a minor problem with the length, if you write the command
!slap nick
and if you write
!slap
it will be the same length 1
then somehow I will try, but I would like you to suggest some sort of option how to make !slap replace with random, and not an empty string as with !slap nick