A
A
Angeloffy2021-11-28 18:04:39
Python
Angeloffy, 2021-11-28 18:04:39

How to set permissions when creating discord py text channel?

Good day, I have a piece of code

class User(commands.Cog):
    def __init__(self, client):
        self.client = client
        inter_client = InteractionClient(client)
    @commands.command()

# ВЫВОД СООБЩЕНИЯ
    async def verif(self, ctx):

        emb = discord.Embed(title=f'{ctx.guild.name} - ЗАЯВКА НА БУСТЕРА!',
            description = 
            f"""
             Для подачи заявки на бустера, нажмите кнопку
            """,
            colour = 0x88ddff
        )
        emb.set_thumbnail(url = 'https://upload.wikimedia.org/wikipedia/commons/d/d3/Zxcursed.gif')
        emb.set_author(name = 'Написать')

        row = ActionRow(
            Button(
                style = ButtonStyle.red,
                label = 'Написать',
                custom_id = 'verif_button'
            )
        )
        await ctx.send(embed = emb, components = [row])

# СОЗДАНИЕ ТЕКСТОВОГО КАНАЛА ПО НАЖАТИИ КНОПКИ
    @commands.Cog.listener()
    async def on_button_click(self, inter):
        res = 'Тикет создан!' # вывод сообщение что человек получил тикет
        letters = 'qwertyuiopasdfghjklzxcvbnm1234567890'
        name1 = ''.join(random.choice(letters) for i in range(5))
        guild = inter.guild
        cat = discord.utils.get(inter.guild.categories, name="want be booster")
       member = inter.author
        if inter.component.id == "verif_button":
            
            await guild.create_text_channel(f'╰】・tiket: {name1}', category=cat)
            await inter.reply(res, ephemeral = True)


It is necessary to make it so that the one who pressed the button - ONLY he saw this text channel

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wolf_Yout, 2022-01-03
@Angeloffy

await channel.set_permissions(ctx.author,speak=True,send_messages=True,read_message_history=True,read_messages=True)

And be sure:
Create a separate category that is private and make sure that a new channel is added to it
61d3182e228e3210193853.png61d31841b4c62905693714.png61d31850105ae467552315.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question