Need help with Custom Command

Asked May 25, 2022·3 replies·Last activity 4 years 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.

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 !commandhelper;

!addcom -cd=5 !commandhelper $(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.

3 replies

Hey @Rowdy Lizard!

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
RrLPF7Bcyw.png

Thank you @Polar Cat

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 !commandhelper (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?

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:

js
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:

/t/different-responses-for-different-users/1534643686346854501#m1534643689715…