Open ianfhunter opened 9 months ago
A common solution has been this:
!alias bug embed
-desc "Hi {{"&1&" if "&1&" != "&"+"1&" else ""}}"
Personally I prefer to work with &ARGS&
, as lists of arguments feel cleaner to work with in most cases.
(As a side note, I'd recommend visiting Avrae's Discord server rather than jumping straight to GitHub)
If I want to provide an optional argument to my alias, for example
!myalias debugmode
, the logic inside draconic for parsing arguments is not very helpful.If I call the following code as
!bug hello
and just!bug
The first will print "Hi hello" and the latter "Hi %1%".
I would expect that when %1% is not provided, it would be replaced with an empty string, so we could do something like this:
However, because it's not replaced, it's impossible to detect if the value isn't provided reliably
Will return "%1%" because both sides of the comparison are replaced.
The only workaround I can think of is something like:
However, that would exclude valid inputs like "Hi 100%"
I do not know that the other argument parse types - "%*%", "&1&", etc work any better.
Proposed Solution: If I was writing this code, I would expect these to be replaced with
None
or "" on no argument received