Skip to content

Commit e88d2a8

Browse files
committed
feat: deprecate even more legacy API properties
1 parent 542f220 commit e88d2a8

File tree

1 file changed

+72
-23
lines changed

1 file changed

+72
-23
lines changed

topgg/types.py

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ def parse_bot_dict(d: dict) -> dict:
9292
data["owners"] = [int(e) for e in owners]
9393

9494
# TODO: remove this soon
95-
data["guilds"] = []
95+
data.pop("defAvatar", None)
96+
data.pop("discriminator", None)
97+
data.pop("guilds", None)
98+
data.pop("certifiedBot", None)
9699

97100
for key, value in data.copy().items():
98101
converted_key = camel_to_snake(key)
@@ -106,6 +109,10 @@ def parse_bot_dict(d: dict) -> dict:
106109
def parse_user_dict(d: dict) -> dict:
107110
data = d.copy()
108111

112+
# TODO: remove this soon
113+
data.pop("discriminator", None)
114+
data.pop("certifiedDev", None)
115+
109116
data["social"] = SocialData(**data.get("social", {}))
110117

111118
return data
@@ -205,15 +212,9 @@ class BotData(DataDict[str, t.Any]):
205212
username: str
206213
"""The username of the bot."""
207214

208-
discriminator: str
209-
"""The discriminator of the bot."""
210-
211215
avatar: t.Optional[str]
212216
"""The avatar hash of the bot."""
213217

214-
def_avatar: t.Optional[str]
215-
"""The avatar hash of the bot's default avatar."""
216-
217218
prefix: str
218219
"""The prefix of the bot."""
219220

@@ -238,18 +239,12 @@ class BotData(DataDict[str, t.Any]):
238239
owners: t.List[int]
239240
"""The IDs of the owners of the bot."""
240241

241-
guilds: t.List[int]
242-
"""The guilds the bot is in."""
243-
244242
invite: t.Optional[str]
245243
"""The invite URL of the bot."""
246244

247245
date: datetime
248246
"""The time the bot was added."""
249247

250-
certified_bot: bool
251-
"""Whether or not the bot is certified."""
252-
253248
vanity: t.Optional[str]
254249
"""The vanity URL of the bot."""
255250

@@ -265,6 +260,45 @@ class BotData(DataDict[str, t.Any]):
265260
def __init__(self, **kwargs: t.Any):
266261
super().__init__(**parse_bot_dict(kwargs))
267262

263+
@property
264+
def def_avatar(self) -> t.Optional[str]:
265+
"""DEPRECATED: def_avatar is no longer supported by Top.gg API v0. At the moment, this will always be None."""
266+
267+
warnings.warn(
268+
"def_avatar is no longer supported by Top.gg API v0. At the moment, this will always be None.",
269+
DeprecationWarning,
270+
)
271+
272+
@property
273+
def discriminator(self) -> str:
274+
"""DEPRECATED: Discriminators are no longer supported by Top.gg API v0. At the moment, this will always be '0'."""
275+
276+
warnings.warn(
277+
"Discriminators are no longer supported by Top.gg API v0. At the moment, this will always be '0'.",
278+
DeprecationWarning,
279+
)
280+
return "0"
281+
282+
@property
283+
def guilds(self) -> t.List[int]:
284+
"""DEPRECATED: Guilds list is no longer supported by Top.gg API v0. At the moment, this will always be an empty list."""
285+
286+
warnings.warn(
287+
"Guilds list is no longer supported by Top.gg API v0. At the moment, this will always be an empty list.",
288+
DeprecationWarning,
289+
)
290+
return []
291+
292+
@property
293+
def certified_bot(self) -> bool:
294+
"""DEPRECATED: Certified bot is no longer supported by Top.gg API v0. At the moment, this will always be false."""
295+
296+
warnings.warn(
297+
"Certified bot is no longer supported by Top.gg API v0. At the moment, this will always be false.",
298+
DeprecationWarning,
299+
)
300+
return False
301+
268302

269303
class BotStatsData(DataDict[str, t.Any]):
270304
"""Model that contains information about a listed bot's guild count."""
@@ -279,20 +313,21 @@ def __init__(self, **kwargs: t.Any):
279313

280314
@property
281315
def shards(self) -> t.List[int]:
282-
"""DEPRECATED: No longer supported by Top.gg API v0. At the moment, this will always return an empty array."""
316+
"""DEPRECATED: Shard-related data is no longer supported by Top.gg API v0. At the moment, this will always return an empty array."""
283317

284318
warnings.warn(
285-
"No longer supported by Top.gg API v0. At the moment, this will always return an empty array.",
319+
"Shard-related data is no longer supported by Top.gg API v0. At the moment, this will always return an empty array.",
286320
DeprecationWarning,
287321
)
288322
return []
289323

290324
@property
291325
def shard_count(self) -> t.Optional[int]:
292-
"""DEPRECATED: No longer supported by Top.gg API v0. At the moment, this will always return None."""
326+
"""DEPRECATED: Shard-related data is no longer supported by Top.gg API v0. At the moment, this will always return None."""
293327

294328
warnings.warn(
295-
"No longer supported by Top.gg API v0. At the moment, this will always return None.", DeprecationWarning
329+
"Shard-related data is no longer supported by Top.gg API v0. At the moment, this will always return None.",
330+
DeprecationWarning,
296331
)
297332

298333

@@ -343,9 +378,6 @@ class UserData(DataDict[str, t.Any]):
343378
username: str
344379
"""The username of the user."""
345380

346-
discriminator: str
347-
"""The discriminator of the user."""
348-
349381
social: SocialData
350382
"""The social data of the user."""
351383

@@ -355,9 +387,6 @@ class UserData(DataDict[str, t.Any]):
355387
supporter: bool
356388
"""Whether or not the user is a supporter."""
357389

358-
certified_dev: bool
359-
"""Whether or not the user is a certified dev."""
360-
361390
mod: bool
362391
"""Whether or not the user is a Top.gg mod."""
363392

@@ -370,6 +399,26 @@ class UserData(DataDict[str, t.Any]):
370399
def __init__(self, **kwargs: t.Any):
371400
super().__init__(**parse_user_dict(kwargs))
372401

402+
@property
403+
def certified_dev(self) -> bool:
404+
"""DEPRECATED: Certified dev is no longer supported by Top.gg API v0. At the moment, this will always be False."""
405+
406+
warnings.warn(
407+
"Certified dev is no longer supported by Top.gg API v0. At the moment, this will always be False.",
408+
DeprecationWarning,
409+
)
410+
return False
411+
412+
@property
413+
def discriminator(self) -> str:
414+
"""DEPRECATED: Discriminators are no longer supported by Top.gg API v0. At the moment, this will always be '0'."""
415+
416+
warnings.warn(
417+
"Discriminators are no longer supported by Top.gg API v0. At the moment, this will always be '0'.",
418+
DeprecationWarning,
419+
)
420+
return "0"
421+
373422

374423
class VoteDataDict(DataDict[str, t.Any]):
375424
"""Base model that represents received information from Top.gg via webhooks."""

0 commit comments

Comments
 (0)