0
votes

I made a discord bot with discord.py. It works very well in my PyCharm's terminal, when i upload it to the glitch most of the commands are still working but when i tried to create a text channel in "on_message" event, i got a error, i can create the channel but the rest of the code is not working. Here is the error:

Ignoring exception in on_message

Traceback (most recent call last):

  File "/app/.local/lib/python3.7/site-packages/discord/client.py", line 312, in _run_event

    await coro(*args, **kwargs)

  File "HashCubeSupport.py", line 102, in on_message

    await guild.categories[2].create_text_channel(name=name, overwrites=overwrites)

  File "/app/.local/lib/python3.7/site-packages/discord/channel.py", line 842, in create_text_channel

    return await self.guild.create_text_channel(name, overwrites=overwrites, category=self, reason=reason, **options)

  File "/app/.local/lib/python3.7/site-packages/discord/guild.py", line 869, in create_text_channel

    channel = TextChannel(state=self._state, guild=self, data=data)

  File "/app/.local/lib/python3.7/site-packages/discord/channel.py", line 107, in __init__

    self._update(guild, data)

  File "/app/.local/lib/python3.7/site-packages/discord/channel.py", line 131, in _update

    self._fill_overwrites(data)

  File "/app/.local/lib/python3.7/site-packages/discord/abc.py", line 294, in _fill_overwrites

    self._overwrites.append(_Overwrites(id=overridden_id, **overridden))

TypeError: __new__() got an unexpected keyword argument 'allow_new'

And here is the part of the code that causing error:


overwrites = {
            guild.default_role: discord.PermissionOverwrite(read_messages=False),
            guild.me: discord.PermissionOverwrite(read_messages=True),
            guild.roles[v]: discord.PermissionOverwrite(read_messages=True),
            message.author: discord.PermissionOverwrite(read_messages=True)
        }
name = f"test-{message.author.name}-{message.author.discriminator}"
await guild.categories[2].create_text_channel(name=name, overwrites=overwrites)
channel = guild.channels[-1].id
channel2 = client.get_channel(id=channel)
embed = discord.Embed()
embed.add_field(name="Test", value="test", inline=False)
await channel2.send(embed=embed)

If more code is necessary i can show more.

2

2 Answers

0
votes

I solved the problem. I just delete the old project on glitch and create a new one. I pasted the same files on new project. It's weird i know but it worked.

-1
votes

Simply update discord.py

Linux/macOS

python3 -m pip install -U discord.py

Windows

py -3 -m pip install -U discord.py