Hi there, i am trying to add a custom command for my followers. It’s basicly !love command (user loves streamer x%) but i need to limit usage daily for everyone and wanna make exception for myself.
If any follower except me use command, bot replies as "user loves streamer (0-99)%).
If i use command, bot choose random sentence from a pastebin document.
Every user has 86400 seconds cooldown, it basicly a day.
Everything was working fine but after i added [User Command Cooldowns,](https://community.nightdev.com/t/user-command-cooldowns/23839)
bot doesn’t reply me with random sentence.
This is for my love command (i deleted tokens);
!addcom -cd=5 !love -a=_!command_helper $(eval z=86400;d=Date.parse(Date());a=$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)
.match(/~$(user)~\d+~/g);PRIVATE_TOKEN
+(!a||d-parseInt(a[a.length-1].split(~
)[2])>=z*1000?&data=~$(user)~${d}~
:``))
And here _!command_helper;
!addcom -cd=5 _!command_helper $(eval a=$(urlfetch https://twitch.center/customapi/addquote?token=$(query))
;decodeURIComponent($(querystring)
).includes(PRIVATE_TOKEN
)?(a.includes(Successfully added entry
)?$(eval r = $(urlfetch https://decapi.me/random/number/0/99); if ('$(user)' == 'mynickname') "$(eval a=
$(urlfetch json https://pastebin.com/raw/deleted ).split(
|);a[Math.floor(Math.random()*a.length)])"; else '$(user), loves %' +r+ ' streamer!';)
:One usage per!
):
)
Please help me. If need any more information, i can provide.
Emily
May 25, 2022, 10:15pm
2
Hey @foxybiscuit !
Please format your code so it’s easy to read.
You can use this button:
or put it on a new line after four spaces (the line before it must be empty):
empty line
code
or put it between three backticks on the line before and the line after:
```
code
```
Thank you @Emily
i actually fixed my problem but i need some help on another problem.
This is my !love command;
$(eval z=14400;d=Date.parse(Date());a=`$(urlfetch json https://twitch.center/customapi/quote/list?token=Private_Token)`.match(/~$(user)~\d+~/g);`Public_Token`+(!a||d-parseInt(a[a.length-1].split(`~`)[2])>=z*1000?`&data=~$(user)~${d}~`:``))
and this is my _!command_helper (alias of !love) command;
$(eval a=`$(urlfetch https://twitch.center/customapi/addquote?token=$(query))`;decodeURIComponent(`$(querystring)`).includes(`Public_Token`)?(a.includes(`Successfully added entry`)?`$(eval r = $(urlfetch https://decapi.me/random/number/1/100); if ('$(user)' == 'myNickName') {a=`$(urlfetch json https://pastebin.com/raw/)`.split(`|`);a[Math.floor(Math.random()*a.length)];} else {'$(user), beni %' + r + ' seviyor!';})`:`@$(user) Her yayında 1 kez kullanılabilir!`):` `)
So basicly if “anyone” write !love in chat, bot output is like this: anyone, beni %xx seviyor!
Now i want to do that, if xx<15 ‘something’, elseif 15<xx<50 ‘something1’ or ‘something2’ else ‘something3’ or ‘something4’ or ‘something5’.
how i can set that? i know that i need to use pastebin but how can bot read pastebin codes?
1 Like
Emily
June 2, 2022, 10:07am
4
You can write code in your Pastebin and the bot will read it just fine.
If it’s just to extract an array, that’s your Pastebin content:
sentence 1|
sentence 2|
...
sentence N
and then your Nightbot code:
$(eval p='$(urlfetch json https://pastebin.com/raw/XXXXXXXX)'.split('|');)
If it’s to execute code, that’s your Pastebin content:
your extra JS code
and then your Nightbot code:
$(eval $(urlfetch json https://pastebin.com/raw/XXXXXXXX))
But I assume you’re looking for a combination of both, so that’s your Pastebin content:
array = ['sentence 1', 'sentence 2', ... , 'sentence N'];
your extra JS code
and then your Nightbot code:
$(eval $(urlfetch json https://pastebin.com/raw/XXXXXXXX))
I also recommend reading this topic:
Hey @GokuSan !
This may help:
Actually, I have some free time, so let’s fix this.
When using a Pastebin you want to declare your Nightbot variables outside of it, I know your code works, but it’s best practice so if one day you need to use more than one variable, you won’t face an issue.
So here’s how to write your command:
$(eval u = '$(user)'.toLowerCase(); $(urlfetch json https://pastebin.com/raw/XXXXXXXX))
And then inside of your Pastebin have the following code:
switch (u) {
case …
1 Like
system
Closed
June 16, 2022, 10:07am
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.