class Create(disnake.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.value = None
@disnake.ui.button(label="Создать видимый канал", style=disnake.ButtonStyle.green, emoji="", custom_id="Open" )
async def confirm(self, button: disnake.ui.Button, inter: disnake.MessageInteraction):
self.value = True
@disnake.ui.button(label="Создать скрытый канал", style=disnake.ButtonStyle.green, emoji="⛔", custom_id='Hide')
async def cancel(self, button: disnake.ui.Button, inter: disnake.MessageInteraction):
self.value = True
@bot.event
async def on_button_click(interaction):
if interaction.component.custom_id == 'Hide':
guild = interaction.guild
overwrites = {
guild.default_role: disnake.PermissionOverwrite(view_channel=False),
interaction.user: disnake.PermissionOverwrite(view_channel=True, move_members=True, mute_members=True),
get(guild.roles, id=1078705520782880839): disnake.PermissionOverwrite(view_channel=True)}
category = get(guild.categories, id=1051756241711538238)
channel = await guild.create_voice_channel(name=f"Скрытый канал участника: {interaction.user.name}", reason=None, category=category, overwrites=overwrites)
elif interaction.component.custom_id == 'Open':
guild = interaction.guild
overwrites = {
guild.default_role: disnake.PermissionOverwrite(view_channel=True),
interaction.user: disnake.PermissionOverwrite(view_channel=True, move_members=True, mute_members=True)}
categor = get(guild.categories, id=1051756241711538238)
channel = await guild.create_voice_channel(name=f"Открытый канал участика: {interaction.user.name}", reason=None, category=categor, overwrites=overwrites)