Discord.py Glitch or random error: TypeError: __new__() got an unexpected keyword argument 'deny_new'

Discord pushed a new change that changes the overwrites object.

Just reinstall the latest version of Discord.py

python3 -m pip install -U discord.py

That's it.


An alternate option, if you are stuck with an older version of discord.py and would rather not have to update 10k+ lines of code right now, is the following quick and dirty patch I came up with based on this commit:

--- channel.py.old  2017-02-27 15:02:23.000000000 -0800
+++ channel.py  2020-07-22 02:44:03.000000000 -0700
@@ -27,13 +27,28 @@
 from . import utils
 from .permissions import Permissions, PermissionOverwrite
 from .enums import ChannelType
-from collections import namedtuple
 from .mixins import Hashable
 from .role import Role
 from .user import User
 from .member import Member
 
-Overwrites = namedtuple('Overwrites', 'id allow deny type')
+class Overwrites:
+    __slots__ = ('id', 'allow', 'deny', 'type')
+
+    def __init__(self, **kwargs):
+        self.id = kwargs.pop('id')
+        self.allow = kwargs.pop('allow', 0)
+        self.deny = kwargs.pop('deny', 0)
+        self.type = kwargs.pop('type')
+
+    def _asdict(self):
+        return {
+            'id': self.id,
+            'allow': self.allow,
+            'deny': self.deny,
+            'type': self.type,
+        }
+
 
 class Channel(Hashable):
     """Represents a Discord server channel.

(note: this is diff'd against discord.py 0.16.7. It may be slightly different depending on what version of discord.py you're running.)

I must stress that this is a hack at best, and there are no guarantees as to how long this will continue to work. Furthermore, there are no guarantees that Discord won't suddenly introduce some other random API change that will break older discord.py in new and interesting ways. You (like I) should really update your code to comply with the newer discord.py. I only present this workaround as I suspect you are in the same situation as me (having things suddenly break and needing to get things back up and running RIGHT NOW but not having the time to quickly update 10k+ lines of code to fix this.


I just had this issue and just now fixed it, and here is what I did (this worked for my laptop running Windows):

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

I also am running a discord bot on a Raspberry Pi and this is how I fixed it:

pip uninstall discord.py
pip install discord.py
python3 -m pip install -U discord.py