【问题标题】:errors with content discord.py内容 discord.py 的错误
【发布时间】: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.contentsay 是您的函数的名称,而不是包含消息的变量。

标签: python discord discord.py


【解决方案1】:

不要使用say.content。变量say 不是输入的消息,而是函数的函数/名称。

尝试使用ctx.message.content 而不是say.content

【讨论】:

    猜你喜欢
    • 2022-09-23
    • 2022-12-15
    • 2021-08-14
    • 2021-02-20
    • 2021-01-16
    • 2021-01-28
    • 2017-05-22
    • 2021-04-21
    • 2021-04-09
    相关资源
    最近更新 更多