Yardım (Python) Embed Mesajına Button Ekleme

El Chavo#0100
Katılım
27 Kas 2022
Mesajlar
3
Tepkime puanı
0
Şehir
Yalova
Merhaba bot komut kullanınca bir embed mesajı gönderiyor ve ben bu embed mesajına bir button eklemek isrtiyorum. Bunu nasıl yaparım? (Embed mesajının kodları falan hazır sadece buton eklemek için gerekli olan kod lazım
 
alperen.php#7777
Katılım
6 Ocak 2022
Mesajlar
10
Tepkime puanı
3
Şehir
Adana
Merhaba aşağıda yazdığım kod yardım edebilir.

Python:
import discord

client = discord.Client()

@client.event
async def on_reaction_add(reaction, user):
    if reaction.emoji == '👍':
        embed = discord.Embed(title='Sürpriz!', description='Bu bir Embed mesajıdır.', color=0xff0000)
        await reaction.message.channel.send(embed=embed)
 

kedy

.gg/amongusturkiye
Yönetici
kedy0
Katılım
14 Eyl 2021
Mesajlar
379
Tepkime puanı
322
Şehir
İstanbul
Python:
import discord
from discord.ui import Button, View
from discord.ext import commands


class Buttons(discord.ui.View):
    def __init__(self, ctx):
        super().__init__(timeout=5)
        self.ctx = ctx

    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        await interaction.response.edit_message(content=f"This is an edited button response!")
    
    @discord.ui.button(label="Clear",style=discord.ButtonStyle.red)
    async def red_button(self,interaction:discord.Interaction,button:discord.ui.Button):
        self.clear_items()
        await interaction.response.edit_message(view=self)
    
    async def on_timeout(self):
        await self.message.edit(view=None)


@bot.command()
async def button(ctx):
    view = Buttons(ctx)
    msg = await ctx.send("This message has buttons!", view=view)
    view.message = msg
 

Konuyu 0 kişi okuyor. (0 kayıtlı üye ve 0 ziyaretçi)

Benzer konular

  • Bilgi