Кнопки в Pycord необязательно делаются через класс. Вы можете просто создать объект Button
, добавить его в объект View
и отправить. Ниже код для вашего запроса:
import discord
from discord.ext import commands
bot = commands.Bot(intents = discord.Intents.all())
@bot.slash_command(name = 'abcd')
async def abcd(ctx):
list = ['a', 'b', 'c', 'd']
global click_counter
click_counter = 0
button = discord.ui.Button(
label = list[click_counter],
style = discord.ButtonStyle.grey,
custom_id = list[click_counter]
)
async def callback(interaction):
global click_counter
click_counter += 1
if click_counter == 4:
button.label = 'Stop pressing'
button.custom_id = 'nmp'
button.disabled = True
button.callback = None
view = discord.ui.View(button, timeout = None)
await interaction.response.edit_message(content = 'Stop pressing', view = view)
return
button.label = list[click_counter]
button.custom_id = list[click_counter]
view = discord.ui.View(button, timeout = None)
await interaction.response.edit_message(content = list[click_counter], view = view)
button.callback = callback
view = discord.ui.View(button, timeout = None)
await ctx.respond(content = list[click_counter], view = view)
bot.run('token')