From 1169a09d4806246aea01393fbc748fcd16b5af00 Mon Sep 17 00:00:00 2001 From: Sorunome <mail@sorunome.de> Date: Thu, 25 Oct 2018 20:39:32 +0200 Subject: [PATCH] make chanfix go over guilds to not upload the guild icon for each channel --- src/channelsyncroniser.ts | 4 ++-- tools/chanfix.ts | 18 ++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/channelsyncroniser.ts b/src/channelsyncroniser.ts index bb0939a..6e1f9b3 100644 --- a/src/channelsyncroniser.ts +++ b/src/channelsyncroniser.ts @@ -61,7 +61,7 @@ export class ChannelSyncroniser { } } - public async OnGuildUpdate(guild: Discord.Guild) { + public async OnGuildUpdate(guild: Discord.Guild, force = false) { log.verbose(`Got guild update for guild ${guild.id}`); const channelStates = []; for (const [_, channel] of guild.channels) { @@ -69,7 +69,7 @@ export class ChannelSyncroniser { continue; // not supported for now } try { - const channelState = await this.GetChannelUpdateState(channel as Discord.TextChannel); + const channelState = await this.GetChannelUpdateState(channel as Discord.TextChannel, force); channelStates.push(channelState); } catch (e) { log.error("Failed to get channel state", e); diff --git a/tools/chanfix.ts b/tools/chanfix.ts index 4c57c85..446f9d2 100644 --- a/tools/chanfix.ts +++ b/tools/chanfix.ts @@ -128,18 +128,12 @@ bridge.loadDatabases().catch((e) => { let delay = config.limits.roomGhostJoinDelay; // we'll just re-use this client.guilds.forEach((guild) => { - guild.channels.forEach((channel) => { - if (channel.type !== "text") { - return; - } - - promiseChain = promiseChain.return(Bluebird.delay(delay).then(() => { - return chanSync.EnsureState(channel).catch((err) => { - log.warn(`Couldn't update rooms for ${channel.id}`, err); - }); - })); - delay += config.limits.roomGhostJoinDelay; - }); + promiseChain = promiseChain.return(Bluebird.delay(delay).then(() => { + return chanSync.OnGuildUpdate(guild, true).catch((err) => { + log.warn(`Couldn't update rooms of guild ${guild.id}`, err); + }); + })); + delay += config.limits.roomGhostJoinDelay; }); return promiseChain; }).catch((err) => { -- GitLab