Ad Error While Trying To Create A Private Channel

- 1 answer

I wanted to make a private channel when a user runs a simple command. The code is below:

async def createChannel(ctx):
    guild = ctx.guild
    member =
    admin_role = get(guild.roles, name = "Admin")
    overwrites = {
        guild.default_role: discord.PermissionOverwrite(read_messages=False),
        member: discord.PermissionOverwrite(read_messages=True),
        admin_role: discord.PermissionOverwrite(read_messages=True)
        channel = await guild.create_text_channel('{}_sentinel'.format(, overwrites=overwrites)

Full traceback:

Ignoring exception in command start:
Traceback (most recent call last):
  File "/Users/raveeshyadav/Raveesh/sentinel/sentinel/lib/python3.9/site-packages/discord/ext/commands/", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/Users/raveeshyadav/Raveesh/sentinel/", line 44, in createChannel
    channel = await guild.create_text_channel('{}_sentinel'.format(, overwrites=overwrites)
  File "/Users/raveeshyadav/Raveesh/sentinel/sentinel/lib/python3.9/site-packages/discord/", line 948, in create_text_channel
    data = await self._create_channel(name, overwrites, ChannelType.text, category, reason=reason, **options)
  File "/Users/raveeshyadav/Raveesh/sentinel/sentinel/lib/python3.9/site-packages/discord/", line 844, in _create_channel
AttributeError: 'NoneType' object has no attribute 'id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/raveeshyadav/Raveesh/sentinel/sentinel/lib/python3.9/site-packages/discord/ext/commands/", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/Users/raveeshyadav/Raveesh/sentinel/sentinel/lib/python3.9/site-packages/discord/ext/commands/", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/Users/raveeshyadav/Raveesh/sentinel/sentinel/lib/python3.9/site-packages/discord/ext/commands/", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'


Error Screenshot



This error is being generated by passing an key with a value of None in overwrites. It's probably admin_role. You can check:

  • You actually have a role named Admin on the guild;
  • You have activated guild intents so that you can have the list of roles.