Как добавить в список того кто нажал кнопку discord.py
import discord
from discord.ext import commands
client=commands.Bot(command_prefix=commands.when_mentioned_or("."), intents=discord.Intents.all())
game = None
def cs():
game = 'cs2'
return game
class Select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="cs2",emoji="?",description="This is option 1!"),
discord.SelectOption(label="dota2",emoji="✨",description="This is option 2!"),
discord.SelectOption(label="valorant",emoji="?",description="This is option 3!"),
discord.SelectOption(label="своя игра",emoji="?",description="This is option 3!")
]
super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
async def callback(self, interaction: discord.Interaction):
if self.values[0] == "cs2":
gadde = 'Counter-Strike 2'
elif self.values[0] == "dota2":
gadde = 'Dota 2'
elif self.values[0] == "valorant":
gadde = 'Valorant'
#start
class Select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="1x1",emoji="?",description="This is option 1!"),
discord.SelectOption(label="2x2",emoji="✨",description="This is option 2!"),
discord.SelectOption(label="5x5",emoji="?",description="This is option 3!")
]
super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
async def callback(self, interaction: discord.Interaction):
if self.values[0] == "1x1":
format = '1x1'
elif self.values[0] == "2x2":
format = '2x2'
elif self.values[0] == "5x5":
format = '5x5'
#start
class Select(discord.ui.Select):
def __init__(self):
options=[
discord.SelectOption(label="CapitansMod",emoji="?",description="This is option 1!"),
discord.SelectOption(label="Random",emoji="✨",description="This is option 2!")
]
super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
async def callback(self, interaction: discord.Interaction):
if self.values[0] == "CapitansMod":
pik = 'CapitansMod'
elif self.values[0] == "Random":
pik = 'Random'
#start
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Подтвердить",style=discord.ButtonStyle.green) # or .primary
async def green_button(self,button:discord.ui.Button,interaction:discord.Interaction):
channel = client.get_channel(1255609180153188453)
members = int(format[0])
members1 = members * 2
members2 = str(members1)
list = []
#start
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Записаться",style=discord.ButtonStyle.blurple) # or .primary
async def blurple_button(self,button:discord.ui.Button,interaction:discord.Interaction):
#list.append()
user_id = interaction.user.id
print(user_id)
#end
view=Buttons()
embed2 = discord.Embed(title='**Новый клоуз **|** '+gadde+' '+pik+'**',description="*Игра:* **"+gadde+"**\n*Формат:* **"+format+"**\n*Пик:* **"+pik+"**\n*Награда: * **250$**\n*Для участия нажмите кнопку ниже*\n*Клоуз начнется когда наберется *"+" **"+members2+"** "+"*участников*", color=discord.Colour.from_rgb(43, 45, 49))
await channel.send(embed=embed2, view=view)
@discord.ui.button(label="Удалить",style=discord.ButtonStyle.red) # or .secondary/.grey
async def red_button(self,button:discord.ui.Button,interaction:discord.Interaction):
await interaction.response.edit_message(view=self)
#end
await interaction.response.edit_message(content=f"*Игра:* **"+gadde+"**\n*Формат:* **"+format+"**\n*Пик:* **"+pik+"**", view=Buttons())
class SelectView(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout=timeout)
self.add_item(Select())
#end
await interaction.response.edit_message(content=f"*Игра:* **"+gadde+"**\n*Формат:* **"+format+"**\n*Выберите формат пика ниже*", view=SelectView())
class SelectView(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout=timeout)
self.add_item(Select())
#end
await interaction.response.edit_message(content='*Игра:* **'+gadde+'**\n*Выберите формат ниже*', view=SelectView())
class SelectView(discord.ui.View):
def __init__(self, *, timeout = 180):
super().__init__(timeout=timeout)
self.add_item(Select())
@client.command()
async def menu(ctx):
await ctx.send("Menus!",view=SelectView())
client.run('
Вот мой код. Как можно сделать чтобы при нажатии кнопки Записаться бот добавлял того кто нажал кнопку в список в сообщении?