Custom command not working

Asked May 9, 2025·3 replies·Last activity 1 year 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.

I'm trying to make a command that counts down to the release of deltarune, with a couple features sprinkled in. namely, nightbot sends a link to a meme when there's 7 days left, and it shows the full countdown when there's less than 3 days left. I tried just putting the full script into the command, but it returns the script instead of evaluating it, despite me using the $(eval) variable. I have also tried using $(urlfetch to pull the script from a github repo), and then again, but with the script in two parts, including the `$(eval) variable. Here is the most recent iteration of the command, which just outputs the code:

!commands edit !dr -cd=10 $(urlfetch https://raw.githubusercontent.com/ProotTheFoxCodes/Nightbot-stuff/refs/heads/main/deltarune-tomorrow/remote/part1.txt)$(urlfetch https://raw.githubusercontent.com/ProotTheFoxCodes/Nightbot-stuff/refs/heads/main/deltarune-tomorrow/remote/part2.txt)";)

Here's a couple older iterations that might make it more clear what I want it to do:

!commands edit !dr -cd=10 $(eval "$(urlfetch https://raw.githubusercontent.com/ProotTheFoxCodes/Nightbot-stuff/refs/heads/main/deltarune-tomorrow/remote/part1.txt)" + "$(urlfetch https://raw.githubusercontent.com/ProotTheFoxCodes/Nightbot-stuff/refs/heads/main/deltarune-tomorrow/remote/part2.txt)";)
!commands edit !dr -cd=10 Deltarune in $(eval const deltr = "$(countdown June 5 2025 0:00:00 AM Etc/GMT+9)";if (deltr.includes("month")) {deltr.slice(0,15) + "of tommorows";} else if ((deltr.charAt(0) == 7) && (deltr.includes("day")) { "https://www.youtube.com/shorts/lF8nYw8EGgI"; } else if ((deltr.charAt(0) <= 3) || !(deltr.includes("day"))) { "$(countdown June 5 2025 0:00:00 AM Etc/GMT+9)";} else {deltr.slice(0,2) + "tommorows"; }👍

3 replies

To get your code to run, try:

Deltarune in $(eval (() => { const deltr = "$(countdown June 5 2025 0:00:00 AM Etc/GMT+9)"; if (deltr.includes("month")) { return deltr.slice(0, 15) + " of tomorrows"; } else if ((deltr.charAt(0) == "7") && deltr.includes("day")) { return "https://www.youtube.com/shorts/lF8nYw8EGgI"; } else if ((parseInt(deltr.charAt(0)) <= 3) || !deltr.includes("day")) { return deltr; } else { return deltr.slice(0, 2) + " tomorrows"; }})()) 👍

works like a treat, thanks! I did end up realising that I checked the conditions in the wrong order, but it's fine now x)