Untitled

mail@pastecode.io avatar
unknown
python
22 days ago
1.2 kB
1
Indexable
Never
class BotaoCall(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
        self.value = None

    @discord.ui.button(label="Criar Canal", style=discord.ButtonStyle.blurple, emoji='<a:mic:1255056681377992855>')
    async def Call(self, interaction: discord.Interaction, button: discord.ui.Button):
        self.value = True
        self.stop()
        call = None
        categoria = interaction.guild.get_channel(id_categoria_tempcall)
        call = await interaction.guild.create_voice_channel(f"{interaction.user.name}",category=categoria)
        await interaction.response.send_message(ephemeral=True,content=f"canal criado {call.mention}")
        canalTemporario.append(call.id)

@tasks.loop(minutes=1)
async def check_empty_channels(interaction: discord.Interaction):
    for channel_id in canalTemporario:
        channel = interaction.guild.get_channel(channel_id)
        if channel and len(channel.members) == 0:
            if interaction.user in channel.members:
                continue
            await channel.delete()
            print(f'Canal deletado {channel.mention}')
            canalTemporario.remove(channel_id)
Leave a Comment