Possible to reference command name in command?

Asked Jan 12, 2023·2 replies·Last activity 3 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.

I am hoping to create a command template of sorts that passes the command itself as a value in a urlfetch. I'm using a custom api endpoint to return a clip with a particular tag. I am planning to create a command that will serve as the template to create subsequent ones. I could probably use an eval to separate the command from the ! and populate the URL parameter or even instruct users to pass a second argument, but I first wanted to find out if it's even possible to reference the command itself within a command.

The goal is to have something along the lines of $(urlfetch http://api.endpoint.com/stuffhere?tag=$(command)
where $(command) is !command without the ! (or with if possible, I could reformat the tag at the endpoint to add the exclamation point)

2 replies

Hey @Frisky Dog!

It's not possible at this point, for example $(query) contains the text that comes after the command name.

I'm not 100% sure how a variable such as $(command) would be useful tho', as you can simply type the command name where the variable would go instead. If you see something I'm missing, do you mind elaborating?

Hi @Polar Cat

Thank you for the response. It's not something I imagine would be particularly useful to many. I was looking for a shortcut to generating commands based off of a template. It's far from necessary as the end goal is easily done through other methods.
I was just searching for whether or not referencing the command name were at all possible and provided hardly enough information to explain why.

I'll just do it the right way 🙂