mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
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
This commit is contained in:
parent
0d5e6e213c
commit
e473f3c775
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user