【发布时间】:2021-07-07 22:00:24
【问题描述】:
当我启动我的不和谐机器人时,on_ready 方法不起作用。该机器人上线,但该方法中的任何代码都不会在命令行中打印。此外,info 命令无法正常工作。这是以前与我编写的另一个机器人一起工作的所有代码,所以我不确定什么是失败的。代码如下。
from discord.ext import commands
import discord
client = discord.Client()
TOKEN = "insert token here"
description = "Bot that does things"
bot = commands.Bot(command_prefix="$", description="testbot")
@bot.event
async def on_ready():
print("Logged in as")
print(bot.user.name)
print(bot.user.id)
print("-----------------")
print("Developed by")
print("me")
@bot.command()
async def info(ctx):
embed = discord.Embed(
title="Commands", description="Here are the commands:", color=0xFFFF00
)
embed.add_field(name="meme", value="gives you a meme", inline=True)
print("Cmd entered")
client.run(TOKEN)
【问题讨论】:
标签: python discord discord.py bots