我正在执行一个命令,将信息从一台服务器记录到主服务器,我想计算在“是”确认后服务器完成日志的次数,然后将其显示在嵌入中。我怎样才能做到这一点? 我的脚本:
@bot.command(name="log")
async def log(ctx, name: str, where: str, too: str, time: str, info: str):
embed = discord.Embed(
colour=discord.Colour.red(), title="Confirm Log?")
embed.add_field(name="Name:", value=name, inline=True)
embed.add_field(name="From:", value=where, inline=True)
embed.add_field(name="Too:", value=too, inline=True)
embed.add_field(name="Time:", value=time, inline=True)
embed.add_field(name="Information:", value=info, inline=False)
await ctx.send("Confirm log? (yes/no)")
await ctx.send(embed=embed)
msg = await bot.wait_for('message', check=lambda message: message.author == ctx.author)
if msg.content.lower() == "yes":
await ctx.send("Sent!")
server = ctx.message.guild.name
channel = bot.get_channel(794856521100034060)
embed = discord.Embed(colour=discord.Colour.green(), title="New Log!", description=f'From {server}')
embed.add_field(name="Name:", value=name, inline=True)
embed.add_field(name="From:", value=where, inline=True)
embed.add_field(name="Too:", value=too, inline=True)
embed.add_field(name="Time:", value=time, inline=True)
embed.add_field(name="Information:", value=info, inline=False)
await channel.send(embed=embed)
答案 0 :(得分:0)
if msg.content.lower() == "yes":
some value in a txt/json/db += 1
...
p.s 发送普通文本和嵌入到一条消息中都没有问题:
await ctx.send("Confirm log? (yes/no)")
await ctx.send(embed=embed)
# could just be
await ctx.send(content='Confirm log? (yes/no)', embed=embed)