aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2020-04-19 18:33:03 -0400
committerRapptz <[email protected]>2020-04-19 18:33:03 -0400
commite473f3c775b26a4bb54b18eb6240757306f4f5c1 (patch)
tree3acaf2cf62244126f6a39a38dbce7b4ad61d7e23
parentDecrement Guild.member_count even if member is not cached (diff)
downloaddiscord.py-e473f3c775b26a4bb54b18eb6240757306f4f5c1.tar.xz
discord.py-e473f3c775b26a4bb54b18eb6240757306f4f5c1.zip
Convert id parameter of Object into int or raise TypeError on failure
This prevents breakage for users who pass in a str as an ID whereas it previously worked. Fix #4002
-rw-r--r--discord/object.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/discord/object.py b/discord/object.py
index 753e9069..1ca96c79 100644
--- a/discord/object.py
+++ b/discord/object.py
@@ -62,7 +62,12 @@ class Object(Hashable):
"""
def __init__(self, id):
- self.id = id
+ try:
+ id = int(id)
+ except ValueError:
+ raise TypeError('id parameter must be convertable to int not {0.__class__!r}'.format(id)) from None
+ else:
+ self.id = id
def __repr__(self):
return '<Object id=%r>' % self.id