【发布时间】:2021-07-15 11:39:27
【问题描述】:
所以我写了这个命令,我认为它会向被标记的成员发送邀请,但显然我错过了一些东西。
它返回此错误:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/core.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Invite' object has no attribute 'ctx'
谢谢。
import discord
from discord.ext import commands
class Invite(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(pass_context=True)
async def invite(self, ctx, member: discord.Member, *argument):
link = await ctx.channel.create_invite(max_uses=1, unique=True)
await member.send(link)
await ctx.send(f'{member.name} has received an invite.')
def setup(client):
client.add_cog(Invite(client))
【问题讨论】:
-
您的问题到底是什么。它不做它应该做的事吗?它会抛出错误吗?请详细说明。
-
我已经编辑了我的问题,很抱歉不清楚
-
请包含完整的回溯
-
@mousetail 这可以吗,或者您希望我从自己的计算机上运行它并发布完整的回溯,因为它在 Heroku 上运行?
-
这看起来不像是完整的回溯,尝试运行
heroku logs -n 1500来获取整个内容,或者尝试调用命令并获取完整的回溯
标签: python discord discord.py bots