I've created some buttons for my Discord bot. The buttons now show up underneath each other while I'd rather have them side-by-side instead. I tried using an ActionRow for this, but that doesn't seem to change anything. Fyi, I'm using Discord.py 1.7.3, so not v2.0.
The current code:
import discord
from discord.ext import commands
import random
import time
from discord_components import *
bot = commands.Bot(command_prefix="!")
@bot.command()
async def test(ctx):
button = Button(
style=ButtonStyle.blue,
custom_id="primary",
label="Blue button",
)
button2 = Button(
style=ButtonStyle.red,
custom_id="secondary",
label="Red button",
)
action_row = ActionRow(components=[button, button2])
await ctx.send("Hello World!", components=action_row)
Any tips?
CodePudding user response:
So the answer was fairly simple. For those who wonder...
Replace:
action_row = ActionRow(components=[button, button2])
await ctx.send("Hello World!", components=action_row)
By:
action_row = ActionRow(button, button2)
await ctx.send("Hello World!", components=[action_row])
There's no need to add a list to the ActionRow.
CodePudding user response:
Last I knew discord.py was abandoned. I have used pycord since then. Although I have not used buttons before they have a row argument for their buttons. I'd suggest taking a look at pycord or maybe whatever discord.py docs you are using for a row
argument to buttons. See their docs here
Example:
button = Button(
style=ButtonStyle.blue,
custom_id="primary",
label="Blue button",
row=1,
)