diff --git a/src/plugins/callTimer/index.tsx b/src/plugins/callTimer/index.tsx index 9d32ad5ec..2924d71ed 100644 --- a/src/plugins/callTimer/index.tsx +++ b/src/plugins/callTimer/index.tsx @@ -71,7 +71,7 @@ export const settings = definePluginSettings({ }); // Save the join time of all users in a Map -type userJoinData = { channelId: string, time: number; guildId: string; }; +type userJoinData = { channelId: string, time: number; guildId: string | null; }; const userJoinTimes = new Map(); /** @@ -84,7 +84,7 @@ const userJoinTimes = new Map(); * unique identifier of the guild (server) to which the user belongs. It is used to associate the * user's join time with a specific guild within the application or platform. */ -function addUserJoinTime(userId: string, channelId: string, guildId: string) { +function addUserJoinTime(userId: string, channelId: string, guildId: string | null) { // create a random number userJoinTimes.set(userId, { channelId, time: Date.now(), guildId }); } @@ -152,11 +152,6 @@ export default definePlugin({ const { userId, channelId, guildId } = state; const isMe = userId === myId; - if (!guildId) { - // guildId is never undefined here - continue; - } - // check if the state does not actually has a `oldChannelId` property if (!("oldChannelId" in state) && !runOneTime && !settings.store.watchLargeGuilds) { // batch update triggered. This is ignored because it @@ -173,7 +168,7 @@ export default definePlugin({ if (channelId !== oldChannelId) { if (channelId) { // move or join - addUserJoinTime(userId, channelId, guildId); + addUserJoinTime(userId, channelId, guildId ?? null); } else if (oldChannelId) { // leave removeUserJoinTime(userId);