CallTimer: fix mappings

This commit is contained in:
thororen1234 2026-05-09 17:04:33 -04:00
parent bcf87fa382
commit 9e2a1b97f9
No known key found for this signature in database

View file

@ -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<string, userJoinData>();
/**
@ -84,7 +84,7 @@ const userJoinTimes = new Map<string, userJoinData>();
* 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);