nextcord icon indicating copy to clipboard operation
nextcord copied to clipboard

`typing.Literal`, `nextcord.Range` and `typing.Union` for choices + ranges + channel types

Open ooliver1 opened this issue 3 years ago • 10 comments

  • [x] #589
  • [ ] #590
  • [x] #591

Summary

use typing.Literal["some", "choices"] instead of SlashOption(choices=["some", "choices"]), nextcord.Range[1, 10] instead of SlashOption(min_value=1, max_value=10) and Union[Textchannel, VoiceChannel] instead of SlashOption(channel_types=[ChannelType.text, ChannelType.voice])

What is the feature request for?

Application commands

The Problem

Currently, using SlashOption has been found to be slightly annoying to work with and pretty verbose in terms of syntax. Having a Range for min/max values and using Literal for choices will be more concise and less janky. Using Union's (typing converts 3.10 piped unions to typing.Union I believe

The Ideal Solution

typing.Literal[1, 2, 3] nextcord.Range[min, max] Union[Channel, Classes]

The Current Solution

str: SlashOption(choices=[some, choices]) int/float: SlashOption(min_value=min, max_value=max) GuildChannel = SlashOption(channel_types=[ChannelType's])

ooliver1 avatar Apr 09 '22 18:04 ooliver1

ill working on typing.Literal part for now.

MaskDuck avatar Apr 10 '22 02:04 MaskDuck

Maybe allowing Enums for choices as well could be useful, especially when there are a lot of options or you are using it elsewhere and want to reduce redundancy.

DenverCoder1 avatar Apr 10 '22 02:04 DenverCoder1

question, how do you rolling out slash commands?

MaskDuck avatar Apr 10 '22 03:04 MaskDuck

ill working on typing.Literal part for now.

I think Dysta said they are working on literal already (about 5 hours ago). It was on the Discord server.

DenverCoder1 avatar Apr 10 '22 03:04 DenverCoder1

The relevant code to change would be the CommandOption constructor and/or the CommandOption.get_type method

DenverCoder1 avatar Apr 10 '22 03:04 DenverCoder1

okay

MaskDuck avatar Apr 10 '22 04:04 MaskDuck

I plan to split this issue into separate parts and include channel unions

ooliver1 avatar Apr 10 '22 10:04 ooliver1

#530 stalls this

ooliver1 avatar Apr 10 '22 10:04 ooliver1

This should be moved from TODO because of the linked PR

EmmmaTech avatar Jul 20 '22 03:07 EmmmaTech

It seems like the Range aspect is still not implemented so it won't be closed by #678

DenverCoder1 avatar Jul 20 '22 04:07 DenverCoder1

Anddddd, this is complete!

ooliver1 avatar Sep 04 '22 15:09 ooliver1