Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum options #1292

Merged
merged 10 commits into from
May 7, 2022
Merged

Enum options #1292

merged 10 commits into from
May 7, 2022

Conversation

Middledot
Copy link
Member

Summary

Add support for Enums to be used for options as an alternative to listing options choices.

example:

class Perms(enums.Enum):
    """Choose permission"""
    admin = 0
    mod = 1
    member = 2

@bot.slash_command()
async def perms(ctx, option: Perms):
    await ctx.respond(option)  # gives an enum object

before:

@bot.slash_command()
async def perms(ctx, option: discord.Option(int, description="Choose permission", choices=[discord.OptionChoice("admin", 0), ...])):
    await ctx.respond(option)  # gives an interger

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, typehinting, examples, ...)

@Middledot Middledot added the feature Implements a feature label Apr 24, 2022
@VincentRPS
Copy link
Member

You should add support for discord.Enum as well

@Lulalaby Lulalaby enabled auto-merge (squash) April 24, 2022 14:51
@Lulalaby
Copy link
Member

Lulalaby commented Apr 24, 2022

Amazing work @Middledot

discord/commands/core.py Outdated Show resolved Hide resolved
discord/commands/core.py Outdated Show resolved Hide resolved
Lulalaby and others added 2 commits April 25, 2022 20:05
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
@Lulalaby Lulalaby requested a review from Dorukyum April 25, 2022 18:05
@Middledot Middledot added the status: awaiting review Awaiting review from a maintainer label May 4, 2022
EmmmaTech
EmmmaTech previously approved these changes May 5, 2022
Lulalaby
Lulalaby previously approved these changes May 5, 2022
Dorukyum
Dorukyum previously approved these changes May 7, 2022
krittick
krittick previously approved these changes May 7, 2022
@krittick
Copy link
Contributor

krittick commented May 7, 2022

Conflicts need to be resolved. Looks good otherwise.

@Lulalaby Lulalaby disabled auto-merge May 7, 2022 20:56
@Lulalaby Lulalaby enabled auto-merge (squash) May 7, 2022 20:56
@Lulalaby Lulalaby dismissed stale reviews from krittick, Dorukyum, EmmmaTech, and themself via 04151a0 May 7, 2022 21:04
@Lulalaby Lulalaby disabled auto-merge May 7, 2022 21:04
@Lulalaby Lulalaby enabled auto-merge (squash) May 7, 2022 21:04
@Pycord-Development Pycord-Development deleted a comment from codecov bot May 7, 2022
@Lulalaby Lulalaby requested a review from krittick May 7, 2022 21:05
@codecov
Copy link

codecov bot commented May 7, 2022

Codecov Report

Merging #1292 (04151a0) into master (6913833) will decrease coverage by 0.02%.
The diff coverage is 12.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1292      +/-   ##
==========================================
- Coverage   33.50%   33.47%   -0.03%     
==========================================
  Files          93       93              
  Lines       17560    17581      +21     
==========================================
+ Hits         5883     5886       +3     
- Misses      11677    11695      +18     
Flag Coverage Δ
pytest 33.47% <12.50%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
discord/commands/core.py 17.60% <6.25%> (-0.04%) ⬇️
discord/commands/options.py 16.21% <18.75%> (-0.28%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6913833...04151a0. Read the comment docs.

@Lulalaby Lulalaby merged commit 7ad078f into Pycord-Development:master May 7, 2022
@Middledot Middledot deleted the enum-options branch May 7, 2022 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Implements a feature status: awaiting review Awaiting review from a maintainer
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

6 participants