Twentysix26 / x26-Cogs

General purpose cogs for Red V3
GNU General Public License v3.0
41 stars 28 forks source link

[Bug] Def Messages User on Deleted Forums/(Threads?) #69

Closed EternalllZM closed 4 months ago

EternalllZM commented 1 year ago

Cog

Describe the bug I believe it is from creating a forum channel, creating a parent post/message, then deleting it. After doing so, attempting to run def messages user on the target results in error. Could also effect threads but have not tested.

To Reproduce

  1. Create forum channel
  2. Make an initial post/message
  3. Delete entire forum channel
  4. Run def messages user against your userid

Expected behavior A plaintext channel ID referencing the deleted forum/thread in the user messages log instead of an error.

Screenshots


Traceback (most recent call last):
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 229, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/red/.local/share/Red-DiscordBot/data/modet/cogs/CogManager/cogs/defender/commands/stafftools.py", line 98, in defmessagesgroupuser
    pages = await self.make_message_log(user, guild=author.guild, requester=author, pagify_log=True,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/red/.local/share/Red-DiscordBot/data/modet/cogs/CogManager/cogs/defender/defender.py", line 204, in make_message_log
    requester_can_rm = channel.permissions_for(requester).read_messages
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/red/redenv/lib/python3.11/site-packages/discord/threads.py", line 421, in permissions_for
    raise ClientException('Parent channel not found')
discord.errors.ClientException: Parent channel not found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/redbot/core/commands/commands.py", line 783, in invoke
    await super().invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1642, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/redbot/core/commands/commands.py", line 783, in invoke
    await super().invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1642, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1023, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 238, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Parent channel not found```
EternalllZM commented 4 months ago

Can no longer replicate this issue. Seems to use the deleted channel ID rather than producing an error. Assumed fixed by updates either to defender or redbot itself.