Twentysix26 / x26-Cogs

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

[Bug] Def Messages cannot process posts in media channels #72

Closed EternalllZM closed 3 weeks ago

EternalllZM commented 1 year ago

Cog

Describe the bug A certain percentage of Discord servers have access to a "Media" channel which is basically a glorified forum channel centered around posting media.

Users who create a post within said channel and then are queried by def messages user will cause the bot to error.

To Reproduce Steps to reproduce the behavior:

  1. Create a media channel
  2. Make sure the bot has view access to the channel
  3. Create a post in media channel (no text alongside initial post [unconfirmed if adding text would workaround])
  4. def messages user <userid of poster>
  5. Bot will error

Expected behavior An attachment string should show instead under the media channel name e.g. [11:18:45](#My new artwork) IMG_01024.png

Considering the error mentions parent channel, it may simply be unable to identify what type of channel Media is.

Screenshots Exception in command defender messages user

Traceback (most recent call last):
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, 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 825, in invoke
    await super().invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1650, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/redbot/core/commands/commands.py", line 825, in invoke
    await super().invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1650, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/red/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1029, 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 244, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Parent channel not found
EternalllZM commented 1 month ago

Was this silently fixed in a recent version? Or, was it fixed through a recent Red update (3.5.10)?.. Maybe even a Discord internal change.

def messages user now working in media channels all of the sudden as well as warden actions.

Can anyone else with access to media channels or knowledge of recent updates confirm? You will need to create a rule that ignores channel matching a forum if testing with actions 👉 https://github.com/Twentysix26/x26-Cogs/issues/76 as warden still cannot identify them through channel matching

EternalllZM commented 3 weeks ago

Since this has no activity I'm going to assume this was fixed due to Red v3.5.10 bumping discord.py to 2.4.0 which allowed visibility into these channels.