File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
packages/bot/src/events/tracking Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1+ import { setTimeout } from 'node:timers';
12import type { GuildSettings, User } from '@prisma/client';
23import { PrismaClient, LevelUpNotificationMode } from '@prisma/client';
34import { DiscordSnowflake } from '@sapphire/snowflake';
@@ -15,7 +16,7 @@ import { templateLevelUpMessage } from '../../util/templateLevelUpMessage.js';
1516
1617@singleton()
1718export default class implements Event<typeof Events.MessageCreate> {
18- private readonly erroredGuilds = new Set<string>();
19+ private readonly erroredUsers = new Set<`${ string}-${string}` >();
1920
2021 public readonly name = Events.MessageCreate;
2122
@@ -172,11 +173,12 @@ export default class implements Event<typeof Events.MessageCreate> {
172173 ];
173174
174175 try {
175- if (!this.erroredGuilds .has(message. guildId)) {
176+ if (!this.erroredUsers .has(`${user.userId}-${user. guildId}` )) {
176177 await message.member!.roles.set(roles);
177178 }
178179 } catch (error) {
179- this.erroredGuilds.add(message.guildId);
180+ this.erroredUsers.add(`${user.userId}-${user.guildId}`);
181+ setTimeout(() => this.erroredUsers.delete(`${user.userId}-${user.guildId}`), 180_000).unref();
180182 logger.warn({ err: error }, 'Failed to set roles for user');
181183 }
182184
You can’t perform that action at this time.
0 commit comments