aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-12-25 11:39:26 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:45 -0800
commit4c9cb1f7a3e8134a11d37f130b115391b3c81b54 (patch)
treec6954f79ae7f446ad0e2235a921e1bc3243d86e4
parentSync: make Role, User, and Diff private (diff)
Sync: allow for None values in Diffs
-rw-r--r--bot/cogs/sync/syncers.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bot/cogs/sync/syncers.py b/bot/cogs/sync/syncers.py
index 0a0ce91d0..8b9fe1ad9 100644
--- a/bot/cogs/sync/syncers.py
+++ b/bot/cogs/sync/syncers.py
@@ -119,14 +119,14 @@ class Syncer(abc.ABC):
message = await ctx.send(f"📊 Synchronising {self.name}s.")
diff = await self._get_diff(guild)
- total = sum(map(len, diff))
+ totals = {k: len(v) for k, v in diff._asdict().items() if v is not None}
- if total > self.MAX_DIFF and not await self._confirm(ctx):
+ if sum(totals.values()) > self.MAX_DIFF and not await self._confirm(ctx):
return # Sync aborted.
await self._sync(diff)
- results = ", ".join(f"{name} `{len(total)}`" for name, total in diff._asdict().items())
+ results = ", ".join(f"{name} `{total}`" for name, total in totals.items())
log.info(f"{self.name} syncer finished: {results}.")
if ctx:
await message.edit(
@@ -237,7 +237,7 @@ class UserSyncer(Syncer):
new_user = guild_users[user_id]
users_to_create.add(new_user)
- return _Diff(users_to_create, users_to_update)
+ return _Diff(users_to_create, users_to_update, None)
async def _sync(self, diff: _Diff) -> None:
"""Synchronise the database with the user cache of `guild`."""