Can you make a command dynamically call another command?

lets say I have these commands
!quote1 “Somebody’s poisoned the water hole”
!quote2 “There’s a snake in my boots”
!quote3 “Reach for the sky!”

but I want to randomly use one of these aliases to call.
!commands add !ramdomquote -a=!quote$(eval Math.random() * (3- 1) + 1)

You can change a command dynamically but I can’t seem to call one. if only we had something like
!commands call !quote$(eval Math.random() * (3- 1) + 1)

A command can only have a single alias. But you can get similar functionality using the twitch.center quote system.

the quote was just an example (although I will be looking at that api) Is there no way for a command to dynamical call another command?

Short answer is nope.

Does that mean there is a long answer?

It’s not possible for a command to dynamically decide its alias. But if you describe what the actual commands are, then maybe there is another way to do what you need.

I was just filling my 20 chars, there isn’t a way to trigger another command through a response.

1 Like

Lets say “mike” is our user
!addplayer !commands add !$(user)_power $(user) has 0 power
!mike_power “mike has 0 power”

Lets say we have another user “tom”
!addplayer !commands add !$(user)_power $(user) has 0 power
!tom_power “tom has 0 power”

Now I would like to make an alias that would work for both
!mypower
for tom the output should be "tom has 0 power"
While mike should be “mike has 0 power”

later i would like to make a command for the mods

!powerup tom
this would update toms message to !tom_power “tom has 1 power”

something like that

Go to https://twitch.center/customapi/quote/generate. You will see three lines. After token= on the first line, you will see your first token. After token= on the second and third lines, you will see your second token. Use these to replace FIRSTTOKEN and SECONDTOKEN before you add the following commands.

!power

$(eval if (`$(query)`){list = `$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`.split(','); power = 0; for (i = 0; i < list.length; i++){if (list[i].toLowerCase() === `$(query)`.toLowerCase()){power++}} `$(query) has ${power} power`}else{`@$(user) enter a username after !power`})

!mypower (alias to !power)

$(user)

!powerup

$(eval if (`$(query)`){`$(urlfetch http://twitch.center/customapi/addquote?token=SECONDTOKEN&data=$(query)%2C)`; `$(query) has been powered up!`} else{`@$(user) enter a username after !powerup`})

There is no need for an !addplayer command, because any name that hasn’t been powered up has 0 power.

1 Like

Thanks so much for this code, am_1! I’ve copied everything over and replaced the 2 tokens, but my powering up doesn’t seem to be saving the power. It confirms the user has been powered up, but all powers still say 0. I did try the quote system by itself in the past… I had only 2 entries and deleted both with !delquote. Still same issue. Any ideas?

I just tested all three commands. They work. You aren’t properly copying the tokens. You need to go to https://twitch.center/customapi/quote/generate and generate NEW tokens. You will see three lines. After token= and before &data= on the first line, you will see your first token. After token= and before &data= on the second and third lines, you will see your second token. Use these to replace FIRSTTOKEN and SECONDTOKEN before you add the commands.

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