#đź”’ button
28 messages · Page 1 of 1 (latest)
@bronze delta
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.
depends. Are you using a GUI or building a webapp?
If neither, then no
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 = ["", "", "", "", "", "", " ", "", "", ""] # 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```
here
i need a link button
I'm not that familiar with discordpy but docs says you can with the interaction method
A hands-on guide to Discord.py
You want to add a view to the message
And add a button to that view
This is natively supported by discord.py
So you don’t need an extra lib such as discord_buttons_plugin
Good luck!
lol i fixed it
It’s !close
Ok
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.