在下面的代码中,我希望机器人在命令运行后等待特定用户的消息。为此,我输入.esug(“。”是命令前缀),它以一条消息响应,要求我输入Minecraft用户名,但是当我输入用户名时,并没有问我应该输入的第二个问题。然后我检查了错误,但是没有错误,这导致我到这里。
以下代码:
import e_sugarcane
import discord
from discord.ext import commands
user = discord.Client()
class info_cmds(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def esug(self, ctx, name=None, profile=None):
authorId = ctx.author.id
if name == None:
embed2 = discord.Embed(
color = discord.Color.blue()
)
embed2.add_field(name="Missing Information", value="```Please Enter your Minecraft Username```")
await ctx.send(embed=embed2)
name = await user.wait_for('message', check=lambda message: message.author == ctx.author)
print(name)
profilesList, uuid, boolean = e_sugarcane.listProfiles(name)
if boolean:
embed3 = discord.Embed(
color = discord.Color.blue()
)
embed2.add_field(name="Missing Information", value="```Please Enter your SkyBlock Profile Name```")
await ctx.send(embed=embed3)
profile = await user.wait_for('message', check=lambda message: message.author == ctx.author)
profileID = profilesList[profile.lower()]
totalESugarcane = e_sugarcane.eSugarcane(uuid, profileID)
else:
profilesList, uuid, boolean = e_sugarcane.listProfiles(name)
profileID = profilesList[profile.lower()]
totalESugarcane = e_sugarcane.eSugarcane(uuid, profileID)
embed1 = discord.Embed(
color = discord.Color.blue()
)
embed1.add_field(name="Amount of Sugar Cane", value=f"```{str(totalESugarcane)}```")
await ctx.send(embed=embed1)```
答案 0 :(得分:0)
应为self.bot.wait_for()
而不是user.wait_for()