Is there a way to extend a command using alias?

Is there a way to use an alias command to extend the evals of an existing command? For example:

$(eval const a = $(query).toLowerCase(); switch(a) { case “what is your ******?”: “My ****** is ************* rex. My ******** are ** and ***”; break; case “who is your daddy?”: “My daddy is Brittler. He created me and gave me personality”; break; case “who are you loyal to?”: “I am loyal to the legendary meme masters ONLY.”; break; case “who are the meme masters?”: “there are only two known meme masters so far. *** and ********.”; break; default: " ";})

So, with alias, I would like to add more variables or “questions” that one can use with the “nightbot” command in order to be able to add more personality to nightbot.

Format your questions and responses like this:

"what is your ******?": "My ****** is ************* rex. My ******** are ** and ***",
"who is your daddy?": "My daddy is Brittler. He created me and gave me personality",
"who are you loyal to?": "I am loyal to the legendary meme masters ONLY.",
"who are the meme masters?": "there are only two known meme masters so far. *** and ********."

Then upload them to https://pastebin.com or some other text hosting website.

Now make a command like this:

$(eval responsesString = "{" + decodeURIComponent(`$(querystring $(urlfetch json https://pastebin.com/raw/A4esPaiX))`) + "}"; query = decodeURIComponent(`$(querystring)`); try {responses = JSON.parse(responsesString); response = " "; for (question in responses) {if (question.toLowerCase() == query.toLowerCase()) {response = responses[question]; break}} response} catch(e) {`Failed to parse responses: ${e.message}: ${responsesString}`.substr(0, 400)})

Replace my link (https://pastebin.com/raw/A4esPaiX) with yours.

1 Like

Thank you so much! This is even better than I expected.

Is there a way to make it not respond if a question is not found in the pastebin document?

That’s already how the command I posted works.

This is the command. I added an @$(user) so nightbot tags the person who calls the command. The thing is, if the question is not found, nightbot will reply by only tagging the user. This is the command:

@$(user) $(eval responsesString = "{" + decodeURIComponent($(querystring $(urlfetch json https://pastebin.com/raw/ww8jrL3w))) + "}"; query = decodeURIComponent($(querystring)); try {responses = JSON.parse(responsesString); response = " "; for (question in responses) {if (question.toLowerCase() == query.toLowerCase()) {response = responses[question]; break}} response} catch(e) {Failed to parse responses: ${e.message}: ${responsesString}.substr(0, 400)})

$(eval s="{"+decodeURIComponent("$(querystring $(urlfetch json https://pastebin.com/raw/A4esPaiX))")+"}";query=decodeURIComponent("$(querystring)");try{responses=JSON.parse(s);response="";for(question in responses){if(question.toLowerCase()==query.toLowerCase()){response=responses[question];break}}(response?decodeURIComponent("$(querystring @$(user) )")+response:" ").substr(0,400)}catch(e){`Failed to parse responses: ${e.message}: ${s}`.substr(0,400)})
1 Like

Again, thanks a lot. I appreciate your time.

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