Vikram Jaisingh
Vikram Jaisingh

Reputation: 5

Why am I getting TypeError with discord.py?

I've been using discord.py for a comfortable 3-4 months. I have maybe 2-3 projects using it, too. When I wanted to make a discord bot for my server which I'm using for Community Service and promoting good Mental Health, I received a TypeError as the output to my code, which at this point just responded to !hello.

Then, assuming I did something wrong (which is like 98% of the time) I tried to run my old discord.py projects that were working literally 4 days ago and I received the same TypeError.

Here is my code:

import discord

TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
client = discord.Client()

@client.event
async def on_message(message):
    print(message.content)

    if message.author == client.user:
        return

    if message.content.startswith('!hello'):
        msg = 'Hello {0.author.mention}'.format(message)
        await message.channel.send(msg)

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

client.run(TOKEN)

And this is the full error I received:

Traceback (most recent call last):
  File "C:/Users/lenovo/PycharmProjects/untitled/WIIT Discord.py", line 24, in <module>
    client.run(TOKEN)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\client.py", line 640, in run
    return future.result()
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\client.py", line 621, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\client.py", line 585, in start
    await self.connect(reconnect=reconnect)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\client.py", line 499, in connect
    await self._connect()
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\client.py", line 463, in _connect
    await self.ws.poll_event()
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\gateway.py", line 471, in poll_event
    await self.received_message(msg)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\gateway.py", line 425, in received_message
    func(data)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\state.py", line 750, in parse_guild_create
    guild = self._get_create_guild(data)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\state.py", line 725, in _get_create_guild
    guild._from_data(data)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\guild.py", line 297, in _from_data
    self._sync(guild)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\guild.py", line 324, in _sync
    self._add_channel(TextChannel(guild=self, data=c, state=self._state))
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\channel.py", line 107, in __init__
    self._update(guild, data)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\site-packages\discord\channel.py", line 131, in _update
    self._fill_overwrites(data)
  File "C:\Users\lenovo\PycharmProjects\untitled\venv\lib\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 'deny_new'

Process finished with exit code 1

I'm by absolutely no means an expert at Python or discord.py, but from what I can tell, either I have entered some wrong value, or there is a problem with the discord.py package. It's more likely that the former happened than the latter, so any help will be appreciated. Thanks!

Upvotes: 0

Views: 172

Answers (2)

Daniel Tam
Daniel Tam

Reputation: 926

Try updating your discord.py or maybe changing or reinstalling your IDE. I recently faced this problem with atom and it was fixed after I reinstalled atom. Make sure to save your projects in a textfile or something.

Upvotes: 0

Exclbr
Exclbr

Reputation: 33

Updating to the latest version of discord.py should fix it:

python3 -m pip install -U discord.py

Upvotes: 3

Related Questions