[英]discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'Latency'
this is my code and every time i run it, is say discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'Latency'这是我的代码,每次我运行它时,都会说 discord.ext.commands.errors.CommandInvokeError: 命令引发异常:AttributeError: 'Bot' object 没有属性 'Latency'
import discord
from discord.ext import commands , tasks
from random import choice
import json
import random
import os
intents = discord.Intents.all()
intents.message_content = True
client = commands.Bot(command_prefix = "+", intents=intents)
status = ["just programming","just chilling"]
@client.event
async def on_ready():
change_status.start()
print('log in successfully. {0.user} is online!'.format(client))
@client.command(name="ping", help="This is a ping command")
async def ping(ctx):
await ctx.send(f"**Pong** Latency: {round(client.Latency * 1000)}ms")
@tasks.loop(seconds=20)
async def change_status():
await client.change_presence(activity=discord.Game(choice(status)))
i tried every thing我尝试了一切
The variable you want to call is latency
with a lowercase l, not an uppercase L.您要调用的变量是小写 l 的
latency
,而不是大写 L。
await ctx.send(f"Latency: {round(client.latency * 1000)}ms")
Both Pycord and discord.py mention the casing of the variable and its usage in their documentation. Pycord和discord.py在它们的文档中都提到了变量的大小写及其用法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.