#đź”’ button

28 messages · Page 1 of 1 (latest)

bronze delta
#

hello, can i make buttons on my python code, if yes how?

full pierBOT
#

@bronze delta

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

fiery cradle
#

If neither, then no

bronze delta
#
from discord_buttons_plugin import Button

# FĂĽge diese Funktion hinzu, um das Leaderboard zu aktualisieren
async def update_leaderboard():
    await bot.wait_until_ready()
    leaderboard_channel = bot.get_channel(int(LEADERBOARD_CHANNEL_ID))
    while not bot.is_closed():
        try:
            sorted_xp = sorted(xp_data.get(str(leaderboard_channel.guild.id), {}).items(), key=lambda x: x[1]["xp"], reverse=True)
            leaderboard_embed = discord.Embed(title="[ALLTIME] VOICE-LEVEL LEADERBOARD", color=discord.Color.blue())
            medals = ["![vc_1](https://cdn.discordapp.com/emojis/1235031390287040552.webp?size=128 "vc_1")", "![vc_2](https://cdn.discordapp.com/emojis/1235031392178667522.webp?size=128 "vc_2")", "![vc_3](https://cdn.discordapp.com/emojis/1235031393910915142.webp?size=128 "vc_3")", "![vc_4](https://cdn.discordapp.com/emojis/1235031395764801587.webp?size=128 "vc_4")", "![vc_5](https://cdn.discordapp.com/emojis/1235031397312233473.webp?size=128 "vc_5")", "![vc_6](https://cdn.discordapp.com/emojis/1235031398797279273.webp?size=128 "vc_6")", "![vc_7](https://cdn.discordapp.com/emojis/1235031400722333707.webp?size=128 "vc_7") ", "![vc_8](https://cdn.discordapp.com/emojis/1235031402609643530.webp?size=128 "vc_8")", "![vc_9](https://cdn.discordapp.com/emojis/1235031404442681405.webp?size=128 "vc_9")", "![vc_10](https://cdn.discordapp.com/emojis/1235031406581907507.webp?size=128 "vc_10")"]  # 10 verschiedene Emojis fĂĽr die Medaillen
            count = 0
            leaderboard_content = ""
            for user_id, data in sorted_xp:
                count += 1
                user = leaderboard_channel.guild.get_member(int(user_id))
                if user:
                    xp = data["xp"]
                    level = xp // 100
                    if count <= 10:
                        leaderboard_content += f"{medals[count-1]} {user.display_name}: Level **{level}**\n"
                if count >= 10:  # 10 Benutzer im Leaderboard anzeigen
                    break
            
            leaderboard_embed.description = leaderboard_content
            
            # FĂĽge das Serverbild als Thumbnail hinzu
            leaderboard_embed.set_thumbnail(url=leaderboard_channel.guild.icon.url)
            
            # FĂĽge das Banner unten im Embed hinzu
            leaderboard_embed.set_image(url="https://cdn.discordapp.com/attachments/679421904271966237/1235031467340333086/rainbow_divider.gif?ex=6632e42f&is=663192af&hm=590ae46ea3c17e03b5f82490fa808751e58f4c6ca809ab1130d8c38d5fcea4c5")
            
            # Lösche die letzte Nachricht, falls vorhanden
            async for message in leaderboard_channel.history(limit=1):
                await message.delete()
            
            # Sende die neue Nachricht
            leaderboard_message = await leaderboard_channel.send(embed=leaderboard_embed)
            
            # Erstelle den Button und sende ihn als separate Nachricht
            button = Button(style=5, label="Dein Link-Text", url="Dein Link hier", disabled=True)  # Dies deaktiviert den Button, damit er nicht erneut geklickt werden kann
            await leaderboard_channel.send("Klick hier", components=[button])
        except Exception as e:
            print(f"Fehler beim Aktualisieren des Leaderboards: {e}")
        await asyncio.sleep(UPDATE_INTERVAL)  # Warte bis zum nächsten Update```
bronze delta
#

i need a link button

fiery cradle
#

I'm not that familiar with discordpy but docs says you can with the interaction method

tight jolt
#

You want to add a view to the message

#

And add a button to that view

#

So you don’t need an extra lib such as discord_buttons_plugin

bronze delta
#

alright, i try

#

thanks

#

/close

tight jolt
#

Good luck!

bronze delta
#

lol i fixed it

tight jolt
bronze delta
#

thanks guys

tight jolt
#

Ok

bronze delta
#

❤️

#

!close

full pierBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.