检测单词然后发送嵌入消息(discord.py)

时间:2020-06-26 00:19:47

标签: python discord discord.py

这是我遇到的代码,我不知道如何解决!有人可以帮我吗?

@client.event
async def on_message(ctx, member: discord.Member, guild: discord.Guild = None):
    member = ctx.member if not member else member
    guild = ctx.guild if not guild else guild

    if "done" in message.content:
        embed = discord.Embed(
            colour=discord.Colour.blue(),
            title="Nickname:",
        )

        embed.add_field(name="User Nickname:",
                        value=str(member.nick), inline=False)
        embed.set_footer(text="Bot coded by Grenadevisuals on instagram!",
                         icon_url=ctx.author.avatar_url)
        embed.set_thumbnail(url=guild.icon_url)

        await message.channel.send(embed=embed)

1 个答案:

答案 0 :(得分:0)

也许这段代码可以帮助您:

@client.event
async def on_message(message):
    if "done" in message.content:
        embed = discord.Embed(
            colour=discord.Colour.blue(),
            title="Nickname:",
        )

        embed.add_field(name="User Nickname:",
                        value=str(message.author.nick), inline=False)
        embed.set_footer(text="Bot coded by Grenadevisuals on instagram!",
                         icon_url=message.author.avatar_url)
        embed.set_thumbnail(url=message.guild.icon_url)

        await message.channel.send(embed=embed)

结果:

Result

P.S。如果需要更多参数,可以在message参数后面的函数中添加这些参数,例如:message, member: discord.Member, guild: discord.Guild = None