Oh no :< I’m not sure how to do that on my own, could you walk me through how to fix this?
sure thing ^^
before we begin the updated functionality, do u wish to save the current count u already have saved in there?
if u do, there r a couple of options… u could write down the totals for each name manually… or create a new token set for the quote system to store the new data… but either way u’ll need an extra command to retrieve the data in a usable format… well, or u could go super analog and just pull up the quote list and count them all yourself…
if u don’t, u can simply clear the data and start over
but lemme know on that part, meanwhile i’ll get started on the updated functionality ^^
ok, so for the first command in the aliased set for the new functionality…
$(eval a="$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=$(user))".split(` `);if(a[1]==0){a[2]=1};a[0]==`0.`||a[0]==`No`||a[0]==`There`?`0 $(user) 1 add`:`${a[0].replace(`.`,``)} $(user) ${(a[2]*1)+1} edit`)
and then for the second command in the aliased set…
$(eval a=`$(urlfetch https://twitch.center/customapi/$(4)quote?token=PRIVATE_TOKEN&data=$(query))`;x=`$(3)`*1;x&&a.includes(`Success`)?`$(2) has lurked ${x} time${x==1?``:`s`}${(x=>x>=50?`, masterful!`:x>=25?`, so sneaky!`:`.`)(x)}`:`Error, try again later`)
don’t forget to change PUBLIC_TOKEN to the 8 digit token and PRIVATE_TOKEN to the 16 digit token for an empty quote list
i kept the “masterful!” along with the “sneaky!” from the example above… it’s not as pretty cause i shortened a few things to give more room in the command to add other options beyond sneaky and masterful if u wish, but the same rules apply from above ^^
also, @Emily i’m quite curious y it needs the parenthesis around the function and again with the variable to make it work within the curly braces (i’ve always just defined the function earlier and called it from within the curly braces)
I don’t mind losing the count I have now. Thank you
do u know how to clear the data? with the delquote
command and the &clear=1
Are you referring to this bit of code?
That’s the syntax when you want to write an entire function within template literals, instead of the function name, you have the entire function, the first x
in the function is the name of the variable for the function, but the last x
is the const that we feed to the function.
I could rewrite the code a bit so it’s easier to understand:
- const x = list.filter(item => item === user).length + 1;
+ const usernameAmount = list.filter(item => item === user).length + 1;
if (add.includes('Successfully added')) {
- `${user} has lurked ${x} times${(x =>
+ `${user} has lurked ${usernameAmount} times${(x =>
x >= 50 ? ', masterful!' :
x >= 25 ? ', so sneaky!' :
'.'
- )(x)}`;
+ )(usernameAmount)}`;
} else { 'There was an error, try again later'; }
But of course, I could have extracted the function outside too, which may help you understand the syntax:
const x = list.filter(item => item === user).length + 1;
const extraMessage = (x) => {
if (x >= 50) return ', masterful!';
if (x >= 25) return ', so sneaky!';
return '.';
}
if (add.includes('Successfully added')) {
`${user} has lurked ${x} times${extraMessage(x)}`;
} else { 'There was an error, try again later'; }
Instead of having:
((variable) => /*function code*/)(variable)
You have:
functionName(variable)
and functionName
refers to:
(variable) => /*function code*/
Hope that helps.
well i woulda kept the ternary, but yeah, that extraction is what i normally would’ve done… the only part i dun really understand is the variable afterwards… seems random, lol
I don’t speak smart, what am I supposed to do right now?
It’s just how you feed a variable to a function, same old thing, it just looks a bit different because of the context.
Ignore my long message, I was explaining something to @tiwosslave.
If you want to purge all your current data, go to the following URL:
https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1
That’s what @tiwosslave was suggesting you do:
oooooohh, because it’s an anonymous function, the entire function becomes the function call… that’s pretty cool, thankies
I don’t think that will be necessary, but is it true that the command can only list a finite amount of people?
Yes, the maintainer of the quote API started limiting the amount of quotes because too many people were using it as a database, running a server isn’t free, I believe you can request the limit to be lifted once you reach it, but I doubt it’ll be approved for people who use it as a database.
I realize I’m part of the problem as I was promoting the use of the quote API as a database by creating commands for people which used that API in this way, so I stopped doing that, I don’t even help anymore when people have issues with the quote API if they’re using it as a database (which wasn’t your case: your issue wasn’t with the API), besides I believe we—volunteers—have created enough commands that people should be able to figure out how to create their own, I think we’ve covered the most common requests people would come up with, people just have to search the forum now.
in order for the commands i gave u to work properly it must start with an empty quote list… the current data in your quote list will cause the command to fail
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.