【发布时间】:2021-03-23 14:04:03
【问题描述】:
起初,当我在一个文件中为我的 discord 机器人创建所有命令而不在 cogs 中重新组织它时,一切都运行良好。现在我创建了 cogs(并将我的 ping 命令放在那里),我的程序不再将“延迟”识别为属性。我的其余命令(ban、unban、kick、clearText)奇怪地仍然正常运行,没有任何错误。
import discord
from discord.ext import commands
class basicComs(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def ping(self, ctx):
await ctx.send(f"Pong {round(commands.latency * 1000)}ms")
def setup(client):
client.add_cog(basicComs(commands))
错误信息是:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.ext.commands' has no attribute 'latency'
谢谢:)
【问题讨论】:
标签: python python-3.x discord discord.py