#How to auto delete a created private guild channel?

1 messages · Page 1 of 1 (latest)

old osprey
#

Hello, I'm trying to setup an auto-delete feature on created secret channels after x number of minutes but I'm not sure how to achieve this..

Here's the code I made:

@commands.has_any_role(*roles)
async def open(ctx: discord.ApplicationContext, channel):
    """Creates a private text channel""" # description
    guild = ctx.guild
    category = bot.get_channel(category_id)
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(read_messages=False),
        ctx.author: discord.PermissionOverwrite(read_messages=True, send_messages=True, add_reactions=True, read_message_history=True, manage_channels=True)
    }
    channel_name = await guild.create_text_channel(name='{}'.format(channel), category=category, overwrites=overwrites)
    embed = discord.Embed(
        title = 'Success!',
        description = "Channel: {} has been successfully created.".format(channel_name.mention)
    )
    await ctx.respond(embed=embed, ephemeral=True)```
I tried setting the overwrite from ctx.author to guild.me but I can't access it after the channel was created. Please advise? Thanks in advance.
weary vector
#

maybe you just have to replace all permission by discord.PermissionOverwrite(view_channel=True)

#

like

overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(
view_channel = True)
}

old osprey
#

I wonder if I also has to assign permissions to the bot? I noticed it was not listed with perms when the channel got created

weary vector
#

If he don't have the admin permission, you should yes

old osprey
#

ohh how can I do that?

weary vector
#

when you invite the bot to your server

#

like

old osprey
#

I don't want it with admin perms I mean

weary vector
#

so :

overwrites = {
        guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(
view_channel = True),
        bot.user: discord.PermissionOverwrite(
view_channel = True)
}

#

Tell me if it worked

old osprey
#

omg you're a genius 🤣

#

thank you!!!

weary vector
#

no problem

#

see you !!

old osprey
#

see you hearthug

weary vector
#

excuse me but can you use /close

#

@old osprey ?

#

thanks

#

okay thanks

old osprey