Creating commands involving modified lists

How would I create a list of admins, and then create a command that would list all admins and link their twitches?

Like, if I have Admin1 Admin2 Admin3, I need to have a command that links to twitches of Admins1,2 and 3. But if I wanted to add an Admin4, I’d like a list that !admins would draw from so I could add to the list.

!addcom !admins Hi guys, the links to admins’ twitches are twitch.tv/admin1 , twitch.tv/admin2, twitch.tv/admin3 .

Then !addcom !addadmin -a=!editcom !admins ____________ twitch.tv/admin4

Such that !admins would then read Hi guys, the links to admins’ twitches are twitch.tv/admin1 , twitch.tv/admin2, twitch.tv/admin3, twitch.tv/admin4 .

Is it 4 admins? or were you planning on adding more? I’m thinking that response from Nightbot is gonna get pretty long, bordering on not being able to get it out.
Also I think in order for your !editcom command to work you would have to copy all that came before the new addition.

I’m not 100% sure but I think the best bet would be to recycle the Quote system.

Actually, I’ve figured out a way not involving !admins. Thanks for the input!

Mind sharing it :)? I’d be interested to see what other approaches would there be!

I’m just going to make individual commands for each admin instead, it’s easier to do and doesn’t involve this complicated potential timeouts.

so !admin1, !admin2 etc

So I’m not sure if this would help you, and it’s probably messy as hell as I’m just getting used to things :stuck_out_tongue: but:
!addcom !admin $(eval var wrong = ["Wrong! $(querystring)"]; var correct = ["twitch.com/$(querystring)"]; '$(querystring)'.trim() == 'Billy' ? (correct) : '$(querystring)'.trim() == 'Bob' ? (correct) : (wrong);)

When you type !admin something, the command will compare your query (something) to “Billy” and “Bob”. If you didn’t type Billy or Bob, it will return “Wrong! query” – But if you do type “Billy” or “Bob” it will return “twitch.tv/query”.
You could change the “correct” output to maybe a Twitch URL, and the “admin” person’s name would get filled out thanks to the “query”.

TL;DR:
If you type !admin Dave, but Dave is not an admin, the command will spit out "Wrong!"
If you type !admin Billy or Bob, it will spit out a twitch.tv/Billy or Bob

It would save you on number of commands, and by having the twitch.tv/ portion of the URL be a variable’s output you save yourself on having to type down the URL for each entry. Although having to do the .trim portion per “Admin” is just as bad lol. Maybe someone can make it tidier?

Edit with the final finished example:
!addcom !admin $(eval var w = ["Admin not found."]; var c = ["$(twitch $(query))"]; '$(query)' == 'billy' || '$(query)' == 'bob' ? (c) : (w);)

1 Like

That’s quite the elegant solution. I can’t think of a better phrasing! Perhaps there’s a way to create an !addadmin such that the trim string gains an additional slot with new admins?

I don’t believe that’s possible without some serious external help from a script… but not 100% sure :disappointed_relieved:

Oh well. Cheers for the thought buddy! :slight_smile:

I think doing it just by using commands and no external help, you would have to use !editcom to edit the contents of the command, and so it wouldn’t be just a matter of adding one more .trim string, it would be a matter of having to add the entire code all over + the extra bits.

Again you may wanna wait and hear from someone with more experience than me, hell wouldn’t take much to know more than me lol… And the whole problem with editing and adding to the command is that eventually the command would get too big to even function, unless we found a way to make my example tidier; you’d still eventually reach a limit but it would at least give you far more room for more names.

Is there a list trim as opposed to individual examples?

I managed to make the command a little tidier using OR instead of blatantly copy pasting an entire thing over (though I’m sure there must be a way to make it even shorter), and using query instead of querystring, because there’s no spaces in Twitch names anyway! so that’s quite a few characters saved that could go towards an extra user lol:

!addcom !admin $(eval var wrong = ["Admin not found."]; var correct = [$(twitch $(query))]; '$(query)'.trim() == 'Billy' || '$(query)'.trim() == 'Bob' ? (correct) : (wrong);)

I don’t personally use Twitch so not 100% sure if that $(twitch) bit has the correct formatting, but that should result in:
!admin anyone but Billy or Bob:
Admin not found.
!admin Billy or Bob:
http://www.twitch.tv/Billy or Bob

Edit with the final finished example:
!addcom !admin $(eval var w = ["Admin not found."]; var c = ["$(twitch $(query))"]; '$(query)' == 'billy' || '$(query)' == 'bob' ? (c) : (w);)

1 Like

That looks neater mate! This’ll be a great start. I don’t know how many of us have individual twitches, but I can always make !admins1 and !admins2 if there are too many of us! Thank you so much, it really is greatly appreciated!

1 Like

You’re very welcome :slight_smile: Always glad to be able to help when I’ve gotten a ton of help from people around here!

As an added note, if you want to save up on even more characters, you could always shorten the variables (wrong / correct) to something like w and c (everywhere you see wrong you replace it with w, then the same with correct).

Lastly, as I understand it Javascript is case sensitive, so if you define an “admin” in that command like Billy or Bob, that’s exactly how users will have to type it out as well, with the first letter also in capitals. So it may be a good idea to make the names fully lowercase? Up to you really!

Edit: And testing the command on Discord right now… I’m not even sure you need the .trim bit lol…

Example with all 3 changes applied:
!addcom !admin $(eval var w = ["Admin not found."]; var c = ["$(twitch $(query))"]; '$(query)' == 'billy' || '$(query)' == 'bob' ? (c) : (w);)

1 Like

This looks fantastic! Monario, this helps so much and SHOULD be able to accommodate us all!

Genuinely, I have little idea on this stuff, so all help is greatly appreciated!

1 Like

Woops! Now it works!
I edited the last example. It was missing the quotation marks around $(twitch $(query)).
Good news is the formatting is okay :smiley: You may be able to make Nightbot’s response to the “Correct” output shorter by further formatting that $(twitch) variable, but that’s only going to consume extra precious characters so I wouldn’t bother :stuck_out_tongue:

1 Like

I wish I could like that more than once bud! I may have to edit it for Twitch usage, but that’ll only cost maybe 5 characters at the most, and this way I can get this thing working far far easier than I would’ve thought! You’ve really helped out, thank you so much :smiley:

1 Like

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