Pycord斜杠命令在Discord中无响应的问题求助
问题:Pycord斜杠命令无响应并抛出AttributeError错误
正在开发一款支持玩家联机游戏的Discord机器人,使用Python 3.10.8和Pycord库,代码如下:
from dotenv import load_dotenv load_dotenv() import discord,os global TOKEN,bot,main,games TOKEN = os.getenv("DISCORD_TOKEN") bot = discord.Bot() main = bot.create_group("nisticks","Nisticks Commands") games = main.create_subgroup("games","Nisticks Games Commands") @games.command(description="Tic Tac Toe") async def ttt(ctx): await ctx.respond("gg") if __name__ == '__main__': bot.add_application_command(main) bot.run(TOKEN)
在Discord中执行斜杠命令/nisticks games ttt后无响应,Python控制台抛出以下错误:
Ignoring exception in on_interaction Traceback (most recent call last): File "C:\Python310\lib\site-packages\discord\commands\core.py", line 124, in wrapped ret = await coro(arg) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 1310, in _invoke await command.invoke(ctx) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 372, in invoke await self.prepare(ctx) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 292, in prepare if not await self.can_run(ctx): File "C:\Python310\lib\site-packages\discord\commands\core.py", line 390, in can_run local_check = cog._get_overridden_method(cog.cog_check) AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Python310\lib\site-packages\discord\bot.py", line 1114, in invoke_application_command await ctx.command.invoke(ctx) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 375, in invoke await injected(ctx) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 132, in wrapped raise ApplicationCommandInvokeError(exc) from exc discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Python310\lib\site-packages\discord\client.py", line 377, in _run_event await coro(*args, **kwargs) File "C:\Python310\lib\site-packages\discord\bot.py", line 1167, in on_interaction await self.process_application_commands(interaction) File "C:\Python310\lib\site-packages\discord\bot.py", line 848, in process_application_commands await self.invoke_application_command(ctx) File "C:\Python310\lib\site-packages\discord\bot.py", line 1118, in invoke_application_command await ctx.command.dispatch_error(ctx, exc) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 418, in dispatch_error local = cog.__class__._get_overridden_method(cog.cog_command_error) AttributeError: type object '_MissingSentinel' has no attribute '_get_overridden_method' Ignoring exception in command nisticks games: Traceback (most recent call last): File "C:\Python310\lib\site-packages\discord\commands\core.py", line 124, in wrapped ret = await coro(arg) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 1310, in _invoke await command.invoke(ctx) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 372, in invoke await self.prepare(ctx) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 292, in prepare if not await self.can_run(ctx): File "C:\Python310\lib\site-packages\discord\commands\core.py", line 390, in can_run local_check = cog._get_overridden_method(cog.cog_check) AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Python310\lib\site-packages\discord\bot.py", line 1114, in invoke_application_command await ctx.command.invoke(ctx) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 375, in invoke await injected(ctx) File "C:\Python310\lib\site-packages\discord\commands\core.py", line 132, in wrapped raise ApplicationCommandInvokeError(exc) from exc discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: '_MissingSentinel' object has no attribute '_get_overridden_method'
已尝试的解决方法
- 执行命令安装Pycord最新版本:
pip install git+https://github.com/Pycord-Development/pycord,但问题仍未解决,寻求帮助。
内容的提问来源于stack exchange,提问作者Ninjago77
相关产品推荐
相关产品推荐

