如何让我的机器人发送一条看起来像discord.py中不同颜色的盒子的消息?

问题描述 投票:0回答:1

我试图制作一条类似于气球消息的消息,但我不知道如何使其发挥作用i wanted it to be like this, could annyone help me?我并不担心如何使其发挥作用,我只是想让它发挥作用。感谢谁尝试做到这一点。

我尝试用枕头制作气球,但我无法使用它,因为它说枕头不可用或其他什么。

@bot.command(name='balloon')

async def create_balloon(ctx, color, *, text): color = color.lower() # 转换为较小的保证一致

# Verifique se a cor fornecida é válida
allowed_colors = ['red', 'blue', 'green', 'yellow', 'purple', 'orange', 'pink']
if color not in allowed_colors:
    await ctx.send("Cor inválida. Escolha entre: red, blue, green, yellow, purple, orange, pink.")
    return

# Crie a mensagem com o balão de conversa formatado
balloon_message = f"```{color}\n{text}\n```"
await ctx.send(balloon_message)
python discord discord.py
1个回答
0
投票

我想这就是你想要的

options = ['red', 'blue', 'yellow'] #add other colors in list

@client.tree.command(name="ballon", description="your description")
async def ballon(interaction: discord.Interaction, color: str):
    if color == 'red':
        embed = discord.Embed(title="Red Ballon", color=discord.Colour.red())
        embed.description = "you have chosen the red ballon!"

    elif color == 'blue':
        embed = discord.Embed(title="Blue Ballon", color=discord.Colour.blue())
        embed.description = "you have chosen the blue ballon!"

    elif color == 'yellow':
        embed = discord.Embed(title="Yellow Ballon", color=discord.Colour.yellow())
        embed.description = "you have chosen the yellow ballon!"

    else:
        embed = discord.Embed(title="Error", color=discord.Colour.red())
        embed.description = "please select one of the following colors: 'blue', 'red', 'yellow'"

    await interaction.response.send_message(embed=embed)
© www.soinside.com 2019 - 2024. All rights reserved.