How many character items can I use and can you use the url command?

Hello, I am trying to create a crate drop game in my chat. I have never done any of this before, but I wrote this code using a few different ideas from here:

My first attempt returned in my twitch chat “Unexpected template string” because I think it was too long what was inside the brackets,

!addcom !cratedrop $(user) reached the crate drop first! $(eval a=[AWM, M24, Mk14, Groza, 6x Scope, 8x Scope, 15x Scope, DMR/SR Suppressor, AUG, P90, AR Suppressor, Ghillie Suit, Lvl 3 Spetznas Helmet, Lvl 3 Military Vest, Lvl 3 Backpack. Adrenaline Syringe, MedKit,];a[Math.floor(Math.random()*a.length)]) was looted!
ModeratorVerifiedNightbot: @oregonmomegon → The command “!cratedrop” has been added successfully.
BroadcasterPrime Gamingoregonmomegon: !cratedrop
ModeratorVerifiedNightbot: oregonmomegon reached the crate drop first! Unexpected template string was looted!

then I tried using $urlfet pastebin and it returned "Code generation from strings disallowed for this context "

!addcom !cratedrop $(user) reached the cratedrop first and found loot! $(eval $(urlfetch json a=[`AWM`, `M24`, `Mk14`, `Groza`, `6x Scope`, `8x Scope`, `15x Scope`, `DMR/SR S - Pastebin.com)) were looted!
ModeratorVerifiedNightbot: @oregonmomegon → The command “!cratedrop” has been added successfully.
BroadcasterPrime Gamingoregonmomegon: !cratedrop
ModeratorVerifiedNightbot: oregonmomegon reached the cratedrop first and found loot! Code generation from strings disallowed for this context were looted!

So after more reading, I got a bit confused if Pastebin will work for returning long strings of individual items, so I tried pastebin and it returned “Code generation from strings disallowed for this context”

I want to create one that has all the pub g loot for each separate map so that in chat my fam can play sort of a text based pub g game you know like old school Zork? Am I too old here lol?

I finally got this code to work:

BroadcasterPrime Gamingoregonmomegon: !addcom !cratedrop $(user) got a crate! $(eval a=[4x,8x,15x,ARSuppressor,DMRSRSuppressor,Lvl 3 Vest,Lvl 3 Helmet,Ghillie,Adrenaline,MedKit,];a[Math.floor(Math.random()*a.length)]) were looted!
ModeratorVerifiedNightbot: @oregonmomegon → The command “!cratedrop” has been added successfully.
BroadcasterPrime Gamingoregonmomegon: !cratedrop
ModeratorVerifiedNightbot: oregonmomegon got a crate! DMRSRSuppressor were looted!
BroadcasterPrime Gamingoregonmomegon: !cratedrop
ModeratorVerifiedNightbot: oregonmomegon got a crate! Ghillie were looted!

because I shortened the characters by removing the weapons, but is there any way to do this with more items in the brackets? I also want to create something similar for Neverwinter and maybe Skyrim…so how would I parse in a long string of individual items, or do I have to break them all up to keep it under the character limits?

What are the current character limits?

Does the url command not work?

Like will nightbot not go to pastebin at all or was that not the same things?

I saw at least a few other examples and only one asking my same question about the “Code generation from strings disallowed for this context” but I did not understand the responses or how to make it work so I apologize if I am repeating a question.

So does Pastebin work or not work with nightbot? I keep seeing different answers, so I am not sure what is going on there?

Thank you and I really love all the information on here. I’m just getting into this stuff and its pretty neat, this seems like a great community of people who help each other.

You have a period after ‘Lvl 3 Backpack’ also you don’t need the last comma in the array.

Oh OK thank you, I was not sure about the last comma in the array. Appreciate that!

Oh so when it says unexpected template string that was because of the period, becasue it broke up the string, I gotcha! look at that you can teach an old dog (or retired lady) new tricks!

2 Likes

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