Skip to content

[Rules]: use @commands.guild_only() decorator.#14

Open
Evanroby wants to merge 1 commit into
BeeHiveSafety:mainfrom
Evanroby:main
Open

[Rules]: use @commands.guild_only() decorator.#14
Evanroby wants to merge 1 commit into
BeeHiveSafety:mainfrom
Evanroby:main

Conversation

@Evanroby

@Evanroby Evanroby commented Aug 8, 2025

Copy link
Copy Markdown

Used @commands.guild_only() decorator so it doesn't give an error when running in dms:

Traceback (most recent call last):
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{HOME}/.local/share/Red-DiscordBot/data/axion/cogs/CogManager/cogs/rules/rules.py", line 25, in send_rules
    rules_channel_id = await self.config.guild(ctx.guild).rules_channel_id()
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{HOME}/redenv/lib/python3.11/site-packages/redbot/core/config.py", line 982, in guild
    return self._get_base_group(self.GUILD, str(guild.id))
                                                ^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'id'

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

Traceback (most recent call last):
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1366, in invoke
    await ctx.command.invoke(ctx)
  File "{HOME}/redenv/lib/python3.11/site-packages/redbot/core/commands/commands.py", line 825, in invoke
    await super().invoke(ctx)
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1650, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "{HOME}/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}/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: AttributeError: 'NoneType' object has no attribute 'id'

Also did Black reformatting, and formatted imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant