0
votes

I'm trying to make a discord bot that creates a channel and then adds permissions for it to a specific role.

here is the code that adds the channel:

    server = message.server
    everyone = discord.PermissionOverwrite(read_messages=False, send_messages=False)
    mine = discord.PermissionOverwrite(read_messages=True)
    await client.create_channel(server, 'secret', (server.default_role, everyone), (server.me, mine))
    overwrite = discord.PermissionOverwrite(read_messages=True, send_messages=True)
    await client.edit_channel_permissions(message.channel,  discord.utils.get(server.roles, name="InFight"), overwrite)

So the bot adds the channel but doesn't give the role "InFight" the permissions specified. Any idea on what the problem is? I think it is the way I mention the role.

1

1 Answers

0
votes

I'm not very familiar with discord.py, but considering you're searching for roles, it probably returns a list. You should try by getting the first result

 rolesearch = discord.utils.get(server.roles, 
 name="InFight")
await client.edit_channel_permissions(message.channel, 
 rolesearch[0], overwrite)

Edit: Also make sure your bot has proper permissions