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

fix: sending polls with PartialWebhook #2624

Merged
merged 6 commits into from
Nov 8, 2024

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
CHANGELOG.md Outdated Show resolved Hide resolved
@JustaSqu1d JustaSqu1d added priority: medium Medium Priority status: awaiting review Awaiting review from a maintainer API Reflection Discords API wasn't correctly reflected in the lib 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

CHANGELOG.md Outdated Show resolved Hide resolved
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Reflection Discords API wasn't correctly reflected in the lib 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