[英]Discord.py Embeded messages not sending from else statement
I'm trying to make a command that takes the user's display name and adds it to a list, "registering" them for an event, but whenever I call the command, it doesn't send the confirmation message of a successful registration.我正在尝试创建一个命令,该命令采用用户的显示名称并将其添加到列表中,为事件“注册”他们,但是每当我调用该命令时,它都不会发送成功注册的确认消息。 But, if I've already registered, it sends that message telling me I already registered.
但是,如果我已经注册,它会发送消息告诉我我已经注册。
Here is my code:这是我的代码:
@client.command()
async def register(ctx, *, message=''):
name = ctx.message.author.display_name
embed = Embed(title='Activity Registration', colour= discord.Colour.blue())
if len(fireteam) == 6:
embed.add_field(name='Fireteam Full', value='There is no space left in the fireteam.', inline=False)
else:
if name in fireteam:
embed.add_field(name='You are already registered', value='You cannot register again.', inline=False)
else:
fireteam.append(name)
embed.add_field(name='Successfully Registered', value = name + ' has successfully registered for: **' + message + '**', inline = False)
embed.add_field(name= 'Current Fireteam:', inline = False)
for person in fireteam:
name = ''.join(person)
embed.add_field(value= name, inline= False)
embed.set_thumbnail(url= ctx.message.author.avatar_url)
await ctx.send(embed=embed)
It seems to only be the embedded messages under the second "else" statements that aren't working as I was able to print the contents of the list (fireteam) that the user's names are stored in to the console on a successful registration and my name was on that list, so it's going meeting the criteria to get to that else statement and run that code.似乎只有第二个“else”语句下的嵌入消息不起作用,因为我能够在成功注册时将用户名存储到控制台的列表(fireteam)的内容打印出来name 在该列表中,因此它将满足到达该 else 语句并运行该代码的条件。 Along with that, if I do "^register" a second time, I get the "you already registered" message to pop up, so it's recording my info, it's just not sending the embedded messages.
除此之外,如果我第二次执行“^注册”,我会弹出“您已经注册”的消息,因此它正在记录我的信息,只是不发送嵌入的消息。
for person in fireteam:
name = ''.join(person)
embed.add_field(value= name, inline= False) # this causes error
add_field cant be called without a name param add_field 不能在没有名称参数的情况下被调用
an alternative way would be另一种方法是
embed.add_field(name = "Current Fireteam", value= "\n".join(fireteam), inline= False)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.