I have been working on this as a side project for like 2 months and for the life of me I can not get the bot to create roles with permissions. Here is what I have.
levels={
"Admin":{"name":"ADMIN","hoist":"1","colour":"0x6F0A0A","permissions":""},
"Moderator":{"name":"WATCHMEN","hoist":"1","colour":"0xFF611A","permissions":"discord.permissions(manage_roles=True,kick_members=True,ban_members=True,create_instant_invite=True,mention_everyone=True,change_nickname=True,manage_nicknames=True,read_message_history,send_messages=True,embed_links=True,send_tts_messages,attach_files=True,external_emojis=True,add-reactions=True)"},
"Member":{"name":"MEMBER","hoist":"0","colour":"0x52D41A","permissions":"discord.permissions(send_messages=True)"},
"Verify":{"name":"VERIFY","hoist":"1","colour":"0xFFFFFF","permissions":"discord.permissions(send_messages=True)"},
}
and
async def cook_roles(ctx):
for level in levels.keys():
guild=ctx.guild
name=levels[level]['name']
hoist=levels[level]['hoist']
colour=levels[level]['colour']
# perms=levels[level]['permissions']
if name == "Admin":
perms=discord.Permissions.all()
else:
perms=discord.Permissions(levels[level]['permissions'])
print=(perms)
await ctx.send(perms)
await guild.create_role(name=name,hoist=hoist,permissions=perms,colour=discord.Colour(int(colour,16)))
Any help is appriciated!
I tried taking away the discord.Permissions() and formatting in perms like this
perms=discord.Permissions(levles[level]['permissions'])
but that didn't work either. (I have tried a host of things and just haven't figured it out.)
Here is a traceback for the first provided answer:
Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 83, in wrapped ret = await coro(*args, **kwargs) File "ny.py", line 483, in build await cook_roles(ctx) File "ny.py", line 551, in cook_roles await guild.create_role(name=name,hoist=hoist,permissions=perms,colour=discord.Colour(int(colour,16))) TypeError: int() can't convert non-string with explicit base
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: int() can't convert non-string with explicit base