简体   繁体   中英

When I have two different embed commands with different urls only one of them will work- Can someone help figure this out for me?

@client.event async def on_message(message): if message.content.startswith('!axb'): embed = discord.Embed(title="Axb :sparkles:", description="9b9t Bot Dev", color=0xf188c9) embed.set_image(url='insert url') await message.channel.send(embed=embed) @client.event async def on_message(message): if message.content.startswith('!opal'): embed = discord.Embed(title="opal :sparkles:", description="9b9t Bot Dev", color=0xf188c9) embed.set_image(url='insert url') await message.channel.send(embed=embed)

Only the last on_message event will work, why don't you use a simple elif statement?

@client.event
async def on_message(message):
    if message.content.startswith('!axb'):
        embed = discord.Embed(title="Axb :sparkles:", description="9b9t Bot Dev", color=0xf188c9)
        embed.set_image(url='insert url')
        await message.channel.send(embed=embed)

    elif message.content.startswith('!opal'):
        embed = discord.Embed(title="opal :sparkles:", description="9b9t Bot Dev", color=0xf188c9)
        embed.set_image(url='insert url')
        await message.channel.send(embed=embed)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM