fix(bot): 🐛 Servers leaderboard now updating.

This commit is contained in:
Nyeki.py
2024-10-19 21:24:29 -03:00
parent 398fc2cb93
commit 9b0deec19e
6 changed files with 66 additions and 51 deletions
+27
View File
@@ -0,0 +1,27 @@
from typing import Callable, Iterable, TypeVar
T = TypeVar("T")
U = TypeVar("U")
def deduplicate(iter: Iterable[T], key: Callable[[T], U] = lambda i: i) -> list[T]:
"""Deduplicates an Iterable.
Args:
iter (Iterable[T]): The iterable with items to deduplicate.
key (Callable[[T], U], optional): The key by which to deduplicate. Defaults to `lambda i: i`.
Returns:
list[T]: A list with the deduplicated items.
"""
found_keys = set()
result = []
for i in iter:
if key(i) not in found_keys:
result.append(i)
return result