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

Implement new selects #1702

Merged
merged 44 commits into from Nov 4, 2022
Merged

Conversation

plun1331
Copy link
Member

@plun1331 plun1331 commented Oct 13, 2022

Summary

https://discord.com/developers/docs/change-log#new-select-menu-components

Information

  • 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, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • 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.

@plun1331 plun1331 changed the title Implement selects v2 Implement new selects Oct 13, 2022
@plun1331 plun1331 added priority: high High Priority feature Implements a feature labels Oct 14, 2022
@plun1331
Copy link
Member Author

Tested with the following code, works very well:

import discord


class View(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=180)

    @discord.ui.select(
        custom_id="string-select",
        options=[
            discord.SelectOption(label='a', value='a'),
            discord.SelectOption(label='b', value='b')
        ]
    )
    async def string_select(self, select, interaction):
        await interaction.response.send_message(str(select.values))

    @discord.ui.user_select(
        custom_id="user-select",
        placeholder="beans",
        max_values=5,
    )
    async def user_select(self, select, interaction):
        await interaction.response.send_message(str(select.values))

    @discord.ui.role_select(
        custom_id="role-select",
        placeholder="beans",
        max_values=5,
    )
    async def role_select(self, select, interaction):
        await interaction.response.send_message(str(select.values))

    @discord.ui.mentionable_select(
        custom_id="mention-select",
        placeholder="beans",
        max_values=5,
    )
    async def mention_select(self, select, interaction):
        await interaction.response.send_message(str(select.values))

    @discord.ui.channel_select(
        custom_id="channel-select",
        placeholder="beans",
        max_values=5,
        channel_types=[discord.ChannelType.category]
    )
    async def channel_select(self, select, interaction):
        await interaction.response.send_message(str(select.values))


intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)


@client.event
async def on_ready():
    print('ready')


@client.event
async def on_message(message):
    if message.content == '!test':
        await message.reply("beans", view=View())


client.run("token")

@plun1331 plun1331 marked this pull request as ready for review October 14, 2022 03:55
@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Merging #1702 (1421c5a) into master (20bed13) will decrease coverage by 0.05%.
The diff coverage is 27.73%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1702      +/-   ##
==========================================
- Coverage   33.19%   33.14%   -0.06%     
==========================================
  Files          96       96              
  Lines       18414    18513      +99     
==========================================
+ Hits         6113     6136      +23     
- Misses      12301    12377      +76     
Flag Coverage Δ
macos-latest-3.10 33.12% <27.73%> (-0.06%) ⬇️
macos-latest-3.11 33.12% <27.73%> (-0.06%) ⬇️
macos-latest-3.8 33.14% <27.73%> (-0.06%) ⬇️
macos-latest-3.9 33.14% <27.73%> (-0.06%) ⬇️
ubuntu-latest-3.10 33.12% <27.73%> (-0.06%) ⬇️
ubuntu-latest-3.11 33.12% <27.73%> (-0.06%) ⬇️
ubuntu-latest-3.8 33.14% <27.73%> (-0.06%) ⬇️
ubuntu-latest-3.9 33.14% <27.73%> (-0.06%) ⬇️
windows-latest-3.10 33.12% <27.73%> (-0.06%) ⬇️
windows-latest-3.11 33.12% <27.73%> (-0.06%) ⬇️
windows-latest-3.8 33.14% <27.73%> (-0.06%) ⬇️
windows-latest-3.9 33.14% <27.73%> (-0.06%) ⬇️

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

Impacted Files Coverage Δ
discord/ui/view.py 26.14% <ø> (ø)
discord/components.py 28.16% <9.09%> (-1.19%) ⬇️
discord/ui/select.py 34.92% <22.44%> (-11.04%) ⬇️
discord/enums.py 78.66% <100.00%> (+0.19%) ⬆️
discord/types/components.py 100.00% <100.00%> (ø)

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 20bed13...1421c5a. Read the comment docs.

@plun1331 plun1331 added the status: awaiting review Awaiting review from a maintainer label Oct 14, 2022
@BobDotCom BobDotCom enabled auto-merge (squash) October 14, 2022 04:13
discord/ui/select.py Outdated Show resolved Hide resolved
discord/ui/select.py Outdated Show resolved Hide resolved
plun1331 and others added 3 commits October 14, 2022 07:15
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
@Dorukyum Dorukyum enabled auto-merge (squash) October 15, 2022 10:16
Dorukyum
Dorukyum previously approved these changes Oct 15, 2022
Copy link
Member

@Dorukyum Dorukyum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM change of plans, see below

Copy link
Member

@BobDotCom BobDotCom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discord/ui/select.py Outdated Show resolved Hide resolved
Co-authored-by: NeloBlivion <41271523+NeloBlivion@users.noreply.github.com>
Swhistler1
Swhistler1 previously approved these changes Oct 30, 2022
discord/components.py Outdated Show resolved Hide resolved
discord/enums.py Outdated Show resolved Hide resolved
discord/types/components.py Show resolved Hide resolved
discord/ui/select.py Outdated Show resolved Hide resolved
@BobDotCom BobDotCom merged commit 8c408fc into Pycord-Development:master Nov 4, 2022
@plun1331 plun1331 deleted the selects-v2 branch November 10, 2022 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Implements a feature priority: high High Priority status: awaiting review Awaiting review from a maintainer
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants