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

'Bot' object has no attribute '_bridge_commands' #1808

Closed
3 tasks done
AnonymousHacker1279 opened this issue Nov 29, 2022 · 1 comment · Fixed by #1815
Closed
3 tasks done

'Bot' object has no attribute '_bridge_commands' #1808

AnonymousHacker1279 opened this issue Nov 29, 2022 · 1 comment · Fixed by #1815
Assignees
Labels
bug Something isn't working

Comments

@AnonymousHacker1279
Copy link

Summary

@bot.bridge_command() inside of a cog causes a crash.

Reproduction Steps

  1. Make a bridge command inside of a cog
  2. Enter bot token
  3. Attempt to start bot
  4. Bot fails to start

Minimal Reproducible Code

# main.py
import discord
from discord.ext import bridge, commands

from cogfile import SampleCog

intents = discord.Intents.all()
bridge_bot = bridge.Bot(command_prefix=commands.when_mentioned_or("!"), intents=intents)

bridge_bot.add_cog(SampleCog())
bridge_bot.run("token")

# cogfile.py

from discord.ext import commands
from discord.ext.bridge import bot


class SampleCog(commands.Cog):

	@bot.bridge_command()
	async def test(self, ctx):
		await ctx.respond("test")

Expected Results

The cog will be added, and the bot will start as in 2.3.0.

Actual Results

The bot crashes with an error and will not start.

Traceback (most recent call last):
  File "C:\Users\Nicholas\Documents\GitHub\TitanBot\test.py", line 9, in <module>
    bridge_bot.add_cog(SampleCog())
  File "C:\Users\Nicholas\Documents\GitHub\TitanBot\venv-3.10\lib\site-packages\discord\cog.py", line 656, in add_cog
    cog = cog._inject(self)
  File "C:\Users\Nicholas\Documents\GitHub\TitanBot\venv-3.10\lib\site-packages\discord\cog.py", line 545, in _inject
    bot._bridge_commands.append(command)
AttributeError: 'Bot' object has no attribute '_bridge_commands'. Did you mean: 'bridge_commands'?

Intents

All

System Information

  • Python v3.10.7-final
  • py-cord v2.3.1-final
  • aiohttp v3.8.3
  • system info: Windows 10 10.0.22621

Checklist

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

Additional Context

Works fine in 2.3.0. Tested on both Python 3.10 and 3.11, same results.

May be related to #1800.

@AnonymousHacker1279 AnonymousHacker1279 added the unconfirmed bug A bug report that needs triaging label Nov 29, 2022
@Middledot Middledot self-assigned this Nov 29, 2022
@poohzaza166
Copy link

i can confirm that this is an actual bug

when removeing the _ in discord/cog.py the error gos away

CUbot is a subclass of commands

`Traceback (most recent call last):
File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 786, in _load_from_module_spec
setup(self)
File "/mnt/sharessd/code/python/utachi/refractor/bot/extendtions/music/main.py", line 536, in setup
client.add_cog(Music(client))
File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 656, in add_cog
cog = cog._inject(self)
File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 545, in _inject
bot._bridge_commands.append(command)
AttributeError: 'CUbot' object has no attribute '_bridge_commands'. Did you mean: 'bridge_commands'?

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

Traceback (most recent call last):
File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/mnt/sharessd/code/python/utachi/refractor/bot/main.py", line 115, in
run()
File "/mnt/sharessd/code/python/utachi/refractor/bot/main.py", line 101, in run
client.load_extension(name='bot.extendtions.music.main')
File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/home/pooh/.local/share/virtualenvs/refractor-9meiG1iJ/lib/python3.10/site-packages/discord/cog.py", line 791, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'bot.extendtions.music.main' raised an error: AttributeError: 'CUbot' object has no attribute '_bridge_commands'`

@Middledot Middledot added bug Something isn't working and removed unconfirmed bug A bug report that needs triaging labels Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants