C
C
Chexit2021-11-10 10:43:05
Python
Chexit, 2021-11-10 10:43:05

Adding rights when creating a channel?

I want to make it so that when a user writes a command, a channel is created in which only he and users with a certain role can see and can write, but for some reason he does not issue rights. Here is the code:

@slash.slash(name = 'order', description = 'создать канал', options = [{"name": "text", "description": "текст", "type": 3, "requied": True}], guild_ids = [907669402181316638])
@client.command(aliase = ['order'])
 
async def order(ctx, *, text):
  nom = random.randint(1000, 99999)
  await ctx.guild.create_text_channel(name=f"order-{nom}")
  await ctx.channel.set_permissions(ctx.author, read_messages=True,
                                                      send_messages=False) 
  await ctx.send(f"Pepega {text}")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-11-10
@Chexit

nom = random.randint(1000, 99999)
You'll get a collision sooner or later. At least check for the presence of the channel and regenerate.
In general, you set the rights only specifically for the author, but do not remove the default rights, and do not set the rights for the role.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question