如何将按钮从一列移动到另一行



我有个问题。我在帖子下面有按钮,它们位于一列中。如何将按钮移动到行而不是列?

import discord
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle
@commands.has_permissions(administrator=True)
@bot.command(pass_context=True)
async def shop(ctx):
data = db.get_info(ctx.author.id)
msg = await ctx.send(f"{ctx.author.mention} Choose a product which the you want buy!nn{zpcoin} Мой баланс: {data['ZPCoin']}",
delete_after=60,
components = 
[
[
Button(style = ButtonStyle.grey, label = '50 ZPCoins = 25.000$', emoji='💰', custom_id='product1'),                  
Button(style = ButtonStyle.grey, emoji='💰', label = '100 ZP Coins = 10.000$', custom_id='product2')
]
])
response = await bot.wait_for('button_click', check = lambda message: message.author == ctx.author)
if response.component.custom_id == 'product1':
await msg.delete()
if data['ZPCoin'] >= 50:
await response.send(f'You bought product 25.000$ in price {zpcoin} 50 ZPCoins!', delete_after=30)
db.save_substract_zp_coins(ctx.author.id, 50)
else:
await ctx.send(f"You miss {zpcoin} {50-data['ZPCoin']} ZP Coins on buy a this product!", delete_after=30)

您必须将它们分隔为两个操作行,而不是一个

import discord
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle
@commands.has_permissions(administrator=True)
@bot.command(pass_context=True)
async def shop(ctx):
data = db.get_info(ctx.author.id)
msg = await ctx.send(f"{ctx.author.mention} Choose a product which the you want buy!nn{zpcoin} Мой баланс: {data['ZPCoin']}",
delete_after=60,
components = 
[
[
Button(style = ButtonStyle.grey, label = '50 ZPCoins = 25.000$', emoji='💰', custom_id='product1')],
[                  
Button(style = ButtonStyle.grey, emoji='💰', label = '100 ZP Coins = 10.000$', custom_id='product2')
]
])
response = await bot.wait_for('button_click', check = lambda message: message.author == ctx.author)
if response.component.custom_id == 'product1':
await msg.delete()
if data['ZPCoin'] >= 50:
await response.send(f'You bought product 25.000$ in price {zpcoin} 50 ZPCoins!', delete_after=30)
db.save_substract_zp_coins(ctx.author.id, 50)
else:
await ctx.send(f"You miss {zpcoin} {50-data['ZPCoin']} ZP Coins on buy a this product!", delete_after=30)```

最新更新