Create a custom command with optional argument and if not, take a default

Asked Jan 2, 2021·3 replies·Last activity 5 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 want to create a custom command with a optional argument and if not, it takes a default command.

For example (my user is riahc3)

!hello user

Bot replies:

Hello user! Welcome

!hello

Bot replies:

Hello riahc3! Welcome

Is there a way to do this?

3 replies

Hey @Jolly Kangaroo!

I'm not sure I understand fully what you're looking for, but hopefully using $(touser) is what you need:

!addcom hello Hello $(touser)! Welcome!

Mmmmm

I was a command that takes a OPTIONAL argument.

!hello

Would reply

Hello riahc3!

!hello anotheruser

Would reply

Hello anotheruser!

Have you given it a try?! It does exactly what you're asking for...