diskord icon indicating copy to clipboard operation
diskord copied to clipboard

Webhook.edit_message leads to internal exception

Open aldalen opened this issue 4 years ago • 0 comments

Summary

Webhook.edit_message throws "AttributeError: PartialWebhookState does not support 'get_reaction_emoji'"

Reproduction Steps

My bot updates an embed on a regular cadence, so I store webhook urls in my database, then iterate through them. When posting the new embed, on some servers, I was seeing this in my logs.

I tried with or without "webhook = await webhook.fetch()" to get the "full webhook" and still ran into the same exception. Seems like something on some servers is causing a path to look for reaction emoji.

Minimal Reproducible Code

async with aiohttp.ClientSession() as session:
            try:
                webhook = diskord.Webhook.from_url(config.webhook, session=session)
                webhook = await webhook.fetch()
            except diskord.InvalidArgument:
                self.logging.error("Error: Webhook invalid. Disabling ID: {}".format(config.pk))
                config.status = "Disabled"
                config.save()
                return

            try:
                await webhook.edit_message(config.message_id, content="", embed=append_advert_if_needed(self.bot, config.server.pk, new_embed, lang=config.locale))

            except AttributeError as error:
                #This is an error in the library
                pass

Expected Results

No exception

Actual Results

Following exception was thrown.

File "mycode/loopsv2.py", line 115, in update_message await webhook.edit_message(config.message_id, content="", embed=append_advert_if_needed(self.bot, config.server.pk, new_embed, lang=config.locale)) File "/lib/python3.9/site-packages/diskord/webhook/async_.py", line 1732, in edit_message message = self.create_message(data) File "/lib/python3.9/site-packages/diskord/webhook/async.py", line 1363, in _create_message return WebhookMessage(data=data, state=state, channel=channel) # type: ignore File "/lib/python3.9/site-packages/diskord/message.py", line 712, in init self.reactions: List[Reaction] = [ File "/lib/python3.9/site-packages/diskord/message.py", line 713, in Reaction(message=self, data=d) for d in data.get("reactions", []) File "/lib/python3.9/site-packages/diskord/reaction.py", line 90, in init ] = emoji or message.state.get_reaction_emoji(data["emoji"]) File "/lib/python3.9/site-packages/diskord/webhook/async.py", line 718, in getattr raise AttributeError(f"PartialWebhookState does not support {attr!r}.") AttributeError: PartialWebhookState does not support 'get_reaction_emoji'.

Intents

None

System Information

  • Python v3.9.9-final
  • diskord v2.6.1-final
  • aiohttp v3.7.4.post0
  • system info: Linux 5.13.19-2-pve #1 SMP PVE 5.13.19-4 (Mon, 29 Nov 2021 12:10:09 +0100)

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shown the entire traceback, if possible.
  • [X] I have removed my token from display, if visible.

Additional Context

No response

aldalen avatar Jan 06 '22 20:01 aldalen