discord nextcord
Сделал себе код на когах, но возникла проблема с кодом, когда прописываю /test, бот не вырисовывает embed.
import nextcord
from nextcord import ButtonStyle
from nextcord.ext import commands
from nextcord.ui import Button, View
from nextcord.ui import Modal
from nextcord.ext import tasks
import config
global admins_active
admins_active = []
client = commands.Bot(command_prefix='!', intents=nextcord.Intents.all())
client.remove_command('help')
class TestEmbed(commands.Cog):
def __init__(self, client):
self.client = client
@nextcord.slash_command(name='test', description='Тестовый вариант', guild_ids=[1043627700444729358])
async def test(self, interaction: nextcord.Interaction):
def getEmbed():
embed = nextcord.Embed(title = 'Test Embed Message',color=nextcord.Colour.from_rgb(47, 49, 54))
if len(admins_active) == 0:
value = 'Участники не записались'
else:
value = '\n'.join(admins_active)
embed.add_field(name='Участники:', value=value)
return embed
myview = View(timeout=None)
accept_button = Button(label="Буду", style=ButtonStyle.green)
denied_button = Button(label='Не буду', style=ButtonStyle.red)
myview.add_item(accept_button)
myview.add_item(denied_button)
async def accept_button_event(interaction1: nextcord.Interaction):
if f'<@(interaction1.user.id)>' in admins_active:
await interaction1.response.send_message('Вы уже записаны в таблицу', ephemeral=True)
else:
admins_active.remove(f'<@(interaction1.user.id)>')
await msg.edit(embed=getEmbed())
async def denied_button_event(interaction1: nextcord.Interaction):
try:
admins_active.remove(f'<@(interaction1.user.id)>')
await msg.edit(embed=getEmbed())
except:
await interaction1.response.send_message('<@1043627701069688921>', embed=getEmbed(), ephemeral=False, view=myview)
def setup(client):
client.add_cog(TestEmbed(client))