Error Check for Birthday Interval

This commit is contained in:
2026-05-21 23:20:07 -04:00
parent 997c0c7262
commit 246121d626
2 changed files with 24 additions and 7 deletions
+9 -3
View File
@@ -85,9 +85,15 @@ export default async(Discord: any, client: BotClient) => {
todayInUserTimezone.getUTCMonth() === month - 1
);
let member = await guild.members.fetch(userId);
if (!member) {
console.warn(`Member with ID ${userId} not found in the guild.`);
let member;
try {
member = await guild.members.fetch(userId);
} catch (err: any) {
if (err?.code === 10007) {
console.warn(`[BirthdayCheck] User ${userId} is no longer in the guild, skipping.`);
} else {
console.error(`[BirthdayCheck] Failed to fetch member ${userId}:`, err);
}
continue;
}
+15 -4
View File
@@ -15,7 +15,13 @@ async function sendTimeOutMessage(client: BotClient, threadChannel: any, roleID:
let helperInChannel = false;
threadMembers.forEach(async(threadMember: any) => {
if(threadMember.user.id == threadChannel.ownerId) return;
let member = await threadChannel.guild.members.fetch(threadMember.user.id);
let member;
try {
member = await threadChannel.guild.members.fetch(threadMember.user.id);
} catch (err: any) {
if (err?.code !== 10007) console.error(`[ThreadCreate] Failed to fetch member ${threadMember.user.id}:`, err);
return;
}
let memberRoles = await member.roles.cache.map((role: any) => role.id);
memberRoles.forEach((role: any) => {
if (helperRoles.includes(role)) {
@@ -26,10 +32,15 @@ async function sendTimeOutMessage(client: BotClient, threadChannel: any, roleID:
setTimeout(async() => {
if(helperInChannel) return;
let threadOwner = await threadChannel.guild.members.fetch(threadChannel.ownerId);
let threadOwner;
try {
threadOwner = await threadChannel.guild.members.fetch(threadChannel.ownerId);
} catch (err: any) {
if (err?.code !== 10007) console.error(`[ThreadCreate] Failed to fetch thread owner ${threadChannel.ownerId}:`, err);
return;
}
let helperChannel = await threadChannel.guild.channels.cache.find((channel: any) => channel.id === "1310993025958150166");
await helperChannel.send({
await helperChannel.send({
content: `<@&${roleID}> **${threadOwner.displayName}** has created ${threadChannel.url}. Please help the user with their ${category} question.`
});
}, ms("5s"));