NAFF icon indicating copy to clipboard operation
NAFF copied to clipboard

feat: add hybrid commands

Open AstreaTSS opened this issue 1 year ago • 4 comments

What type of pull request is this?

  • [x] Non-breaking code change
  • [ ] Breaking code change
  • [x] Documentation change/addition
  • [ ] Tests change

Description

This PR adds hybrid commands, which allow using a slash command as a prefixed command too. Efforts have been taken to make sure the resulting prefixed command is as close to the slash command as possible.

This PR also, mostly by consequence:

  • Adds in HybridContext. An argument has been added to Client to allow setting a custom subclass of HybridContext, too.
  • Allows using custom signatures for prefixed commands. This is a very low level thing and should only be manipulated by those who know what they're doing.
  • Changes prefixed commands to base if it should use a kwarg for a parameter or not based on its parameter type instead of blindly guessing.
  • Adds kind to PrefixedCommandParameter.
  • Adds docs for hybrid commands.

Due to the many, many ways slash commands can be declared, there may be some bugs that I missed (though I did test a number of combinations and options).

Changes

See above. Usually, I would type something out, but I feel like this would be a repeat of the description if I bothered.

Checklist

  • [x] I've formatted my code with Black
  • [x] I've ensured my code works on Python 3.10.x
  • [x] I've tested my code

AstreaTSS avatar Aug 02 '22 18:08 AstreaTSS

Can you go into tests/test_protocols.py and a check that Hybrid contexts are SendableContexts?

silasary avatar Aug 03 '22 04:08 silasary

Done!

AstreaTSS avatar Aug 03 '22 05:08 AstreaTSS

Due to the scope of this PR it should not be merged until we have at least a second trust-worthy reviewer

That said if it hits 14 days since my review without a second, it'll be merged

LordOfPolls avatar Aug 10 '22 09:08 LordOfPolls

Found a little oversight - min/max_length wasn't being respected. That's been fixed with the latest two commits.

AstreaTSS avatar Aug 10 '22 18:08 AstreaTSS