Skip to content

Conversation

tyrantlink
Copy link
Contributor

Summary

When attempting to send a poll through a PartialWebook with wait set to True, an AttributeError is raised. Full example code below

from discord import Client, Intents, Message, Webhook
from discord.abc import GuildChannel
from aiohttp import ClientSession


BOT_TOKEN = 'token'


client = Client(
    intents=Intents.default() | Intents.message_content
)


@client.event
async def on_message(message: Message) -> None:
    if message.author.bot or message.poll is None:
        return

    assert isinstance(message.channel, GuildChannel)

    full_webhook = await message.channel.create_webhook(name='webhook state bug demo')

    async with ClientSession() as session:
        webhook = Webhook.from_url(
            url=full_webhook.url,
            session=session
        )

        await webhook.send(
            poll=message.poll,
            wait=True
        )

    await full_webhook.delete(reason='webhook state bug demo')


if __name__ == '__main__':
    client.run(BOT_TOKEN)

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.
  • I have updated the changelog to include these changes.

@tyrantlink
Copy link
Contributor Author

tyrantlink commented Oct 25, 2024

I don't think the state parameter is artificial comment is necessary, but I left it to match the other methods

Lulalaby
Lulalaby previously approved these changes Oct 25, 2024
@Lulalaby Lulalaby enabled auto-merge (squash) October 25, 2024 13:36
@Lulalaby Lulalaby requested review from JustaSqu1d and removed request for FrostByte266 October 25, 2024 13:36
@tyrantlink tyrantlink changed the title fix: sending polls wilth PartialWebhook fix: sending polls with PartialWebhook Oct 25, 2024
@JustaSqu1d JustaSqu1d added priority: medium Medium Priority status: awaiting review Awaiting review from a maintainer API reflection Discord API isn't correctly reflected python Pull requests that update Python code labels Oct 25, 2024
auto-merge was automatically disabled October 25, 2024 20:26

Head branch was pushed to by a user without write access

Copy link
Member

@Lulalaby Lulalaby left a comment

Choose a reason for hiding this comment

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

LGTM

@Lulalaby Lulalaby enabled auto-merge (squash) November 8, 2024 03:56
@Lulalaby Lulalaby merged commit 1f17777 into Pycord-Development:master Nov 8, 2024
25 checks passed
OmLanke pushed a commit to OmLanke/pycord that referenced this pull request Dec 16, 2024
* fix: add store poll to webhook state

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Signed-off-by: tyrantlink <[email protected]>
Co-authored-by: Lala Sabathil <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API reflection Discord API isn't correctly reflected priority: medium Medium Priority python Pull requests that update Python code status: awaiting review Awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants