【发布时间】:2021-07-10 15:52:54
【问题描述】:
@client.command()
@commands.cooldown(1, 5, commands.BucketType.user)
async def say(ctx, *, response):
if "@" in say.content.contains:
await ctx.send("no")
else:
response = response.replace("(", "")
response = response.replace(")", "")
await ctx.send(response)
我正在努力做到这一点,所以如果你输入 .say 那么任何带有 @ 的东西都会取消命令
错误消息:如果 say.content.contains 中有“@”: AttributeError:“命令”对象没有属性“内容”
上述异常是以下异常的直接原因:
Traceback(最近一次调用最后一次): 文件“/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py”,第 903 行,在调用中 等待 ctx.command.invoke(ctx) 文件“/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py”,第 859 行,在调用中 等待注入(*ctx.args,**ctx.kwargs) 文件“/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py”,第 94 行,已包装 从 exc 引发 CommandInvokeError(exc) discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:'Command'对象没有属性'content'
【问题讨论】:
-
你的意思是
ctx.message.content而不是say.content?say是您的函数的名称,而不是包含消息的变量。
标签: python discord discord.py