diff options
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/gateway/src/commands/utilities.ts | 1 | ||||
| -rw-r--r-- | packages/gateway/src/index.ts | 2 | ||||
| -rw-r--r-- | packages/gateway/src/listeners/channelDeletion.ts | 16 | ||||
| -rw-r--r-- | packages/gateway/src/listeners/clientReady.ts | 12 | ||||
| -rw-r--r-- | packages/gateway/src/listeners/iqdbModeration.ts | 16 | ||||
| -rw-r--r-- | packages/gateway/src/listeners/moderationAgent/index.ts | 49 | ||||
| -rw-r--r-- | packages/gateway/src/listeners/moderationAgent/utilities.ts | 10 | ||||
| -rw-r--r-- | packages/gateway/src/listeners/roleProtection.ts | 12 |
8 files changed, 20 insertions, 98 deletions
diff --git a/packages/gateway/src/commands/utilities.ts b/packages/gateway/src/commands/utilities.ts index 38d7bc2..bc9892d 100644 --- a/packages/gateway/src/commands/utilities.ts +++ b/packages/gateway/src/commands/utilities.ts @@ -592,7 +592,6 @@ export const executeBulkRoleAssignment = async ( if (error.code === 10007 || error.message?.includes("Unknown Member")) { notInGuildCount += 1; - console.log(`User ${userId} is no longer in the guild, skipping ...`); } else { errorCount += 1; } diff --git a/packages/gateway/src/index.ts b/packages/gateway/src/index.ts index 1e1184a..2998a6b 100644 --- a/packages/gateway/src/index.ts +++ b/packages/gateway/src/index.ts @@ -4,8 +4,6 @@ import { handleCommands } from "./commands"; import { handleListeners } from "./listeners"; dotenv.config({ path: "../../.dev.vars" }); -console.log("Discord Token loaded:", process.env.DISCORD_TOKEN ? "Yes" : "No"); -console.log("Token length:", process.env.DISCORD_TOKEN?.length || 0); const client = new Client({ intents: [ diff --git a/packages/gateway/src/listeners/channelDeletion.ts b/packages/gateway/src/listeners/channelDeletion.ts index 36fef79..c99fb51 100644 --- a/packages/gateway/src/listeners/channelDeletion.ts +++ b/packages/gateway/src/listeners/channelDeletion.ts @@ -30,16 +30,12 @@ export const handleChannelDeletion = (client: Client) => { ); if (!channelDeletionLog || !channelDeletionLog.executor) { - console.log("Could not determine who deleted channel, skipping..."); - return; } const executor = channelDeletionLog.executor; if (executor.id === guildOwner.id) { - console.log(`Channel deleted by server owner, allowing...`); - return; } @@ -51,20 +47,20 @@ export const handleChannelDeletion = (client: Client) => { userData = { count: 1, firstDeletion: now }; channelDeletionTracker.set(executor.id, userData); - console.log( + console.warn( `User ${executor.tag} (${executor.id}) deleted first channel`, ); } else { if (now - userData.firstDeletion <= thirtySeconds) { userData.count += 1; - console.log( + console.warn( `User ${executor.tag} (${executor.id}) deleted channel ${userData.count}/2 within 30 seconds`, ); if (userData.count > 2) { - console.log( - `User ${executor.tag} (${executor.id}) exceeded channel deletion limit, resetting roles...`, + console.warn( + `User ${executor.tag} (${executor.id}) exceeded channel deletion limit, resetting roles`, ); try { @@ -77,7 +73,7 @@ export const handleChannelDeletion = (client: Client) => { if (rolesToRemove.size > 0) { await member.roles.set([]); - console.log( + console.warn( `Reset ${rolesToRemove.size} roles for user ${executor.tag}`, ); } @@ -95,7 +91,7 @@ export const handleChannelDeletion = (client: Client) => { userData.count = 1; userData.firstDeletion = now; - console.log( + console.warn( `User ${executor.tag} (${executor.id}) deleted channel, resetting counter (outside 30s window)`, ); } diff --git a/packages/gateway/src/listeners/clientReady.ts b/packages/gateway/src/listeners/clientReady.ts index 2933916..99e8af8 100644 --- a/packages/gateway/src/listeners/clientReady.ts +++ b/packages/gateway/src/listeners/clientReady.ts @@ -3,17 +3,12 @@ import { ROLEPLAY_UMAGRAM_CHANNEL_ID } from "./constants"; export const handleClientReady = (client: Client) => { client.once(Events.ClientReady, async (readyClient) => { - console.log(`Gateway client ready! Logged in as ${readyClient.user.tag}`); - await readyClient.user.setActivity("r/okbuddyumamusume", { type: 3 }); try { const channel = client.channels.cache.get(ROLEPLAY_UMAGRAM_CHANNEL_ID); if (channel && channel.isTextBased()) { - console.log( - "Adding hearts to existing messages in roleplay-umagram channel and threads...", - ); let totalMessageCount = 0; let totalHeartCount = 0; @@ -63,9 +58,6 @@ export const handleClientReady = (client: Client) => { await new Promise((resolve) => setTimeout(resolve, 500)); } - console.log( - `${channelName}: Processed ${messageCount} messages, added ${heartCount} hearts`, - ); return { messageCount, heartCount }; }; @@ -88,7 +80,6 @@ export const handleClientReady = (client: Client) => { ...archivedThreads.threads.values(), ]; - console.log(`Found ${allThreads.length} threads to process`); for (const thread of allThreads) { try { @@ -107,9 +98,6 @@ export const handleClientReady = (client: Client) => { console.error("Error fetching threads:", error); } - console.log( - `Completed: Processed ${totalMessageCount} messages total, added ${totalHeartCount} hearts total`, - ); } } catch (error) { console.error("Error adding hearts to existing messages:", error); diff --git a/packages/gateway/src/listeners/iqdbModeration.ts b/packages/gateway/src/listeners/iqdbModeration.ts index d6c71a7..c914227 100644 --- a/packages/gateway/src/listeners/iqdbModeration.ts +++ b/packages/gateway/src/listeners/iqdbModeration.ts @@ -17,9 +17,6 @@ export const handleIqdbModeration = (client: Client) => { if (imageAttachments.size === 0) return; try { - console.log( - `Processing ${imageAttachments.size} image(s) for iqdb moderation...`, - ); for (const attachment of imageAttachments.values()) { try { @@ -31,8 +28,6 @@ export const handleIqdbModeration = (client: Client) => { ) || []; if (matches.length === 0) { - console.log("No significant matches found in iqdb"); - continue; } @@ -51,9 +46,6 @@ export const handleIqdbModeration = (client: Client) => { } if (booruType) { - console.log( - `Found match on ${booruType}, checking for prohibited tags...`, - ); try { const postId = match.sourceUrl.match(/\/(\d+)/)?.[1]; @@ -107,10 +99,6 @@ export const handleIqdbModeration = (client: Client) => { } } - console.log( - `Retrieved ${tags.length} tags from ${booruType}:`, - tags.slice(0, 10), - ); const prohibitedTags = [ /^(loli|shota)$/i, @@ -134,8 +122,8 @@ export const handleIqdbModeration = (client: Client) => { const similarity = match.similarity!; const isHighConfidence = similarity > 0.75; - console.log( - `Prohibited tags detected: ${foundProhibitedTags.join(", ")}, similarity: ${(similarity * 100).toFixed(1)}%, ${isHighConfidence ? "deleting message" : "sending notification"}...`, + console.warn( + `Prohibited tags detected: ${foundProhibitedTags.join(", ")}, similarity: ${(similarity * 100).toFixed(1)}%, ${isHighConfidence ? "deleting message" : "sending notification"}`, ); const { EmbedBuilder } = await import("discord.js"); diff --git a/packages/gateway/src/listeners/moderationAgent/index.ts b/packages/gateway/src/listeners/moderationAgent/index.ts index c6915c0..84528f7 100644 --- a/packages/gateway/src/listeners/moderationAgent/index.ts +++ b/packages/gateway/src/listeners/moderationAgent/index.ts @@ -25,10 +25,6 @@ export const handleAIModeration = (client: Client) => { if (!message.content && message.attachments.size === 0) return; if (!message.content && message.attachments.size > 0) { - console.log( - `AI Moderation: Skipping attachment-only message (handled by iqdb)`, - ); - return; } @@ -36,8 +32,6 @@ export const handleAIModeration = (client: Client) => { const content = message.content.trim(); if (!content) { - console.log(`AI Moderation: Skipping empty/whitespace message`); - return; } @@ -48,10 +42,6 @@ export const handleAIModeration = (client: Client) => { content.length < MIN_MESSAGE_LENGTH && !shortWhitelist.test(content) ) { - console.log( - `AI Moderation: Skipping short message (${content.length} chars): "${content}"`, - ); - return; } @@ -59,18 +49,12 @@ export const handleAIModeration = (client: Client) => { /^(?:\p{Emoji_Presentation}|\p{Extended_Pictographic}|\s)+$/u; if (emojiRegExp.test(content)) { - console.log(`AI Moderation: Skipping emoji-only message: "${content}"`); - return; } const symbolRegExp = /^[^\p{L}\p{N}\s]+$/u; if (symbolRegExp.test(content)) { - console.log( - `AI Moderation: Skipping symbol-only message: "${content}"`, - ); - return; } @@ -78,24 +62,16 @@ export const handleAIModeration = (client: Client) => { content.replace(/[\p{L}\p{N}\s]/gu, "").length / content.length; if (symbolDensity >= MAX_SYMBOL_DENSITY && content.length > 3) { - console.log( - `AI Moderation: Skipping high symbol density message (${(symbolDensity * 100).toFixed(1)}%): "${content}"`, - ); - return; } for (const pattern of LOW_RISK_PATTERNS) if (pattern.test(content)) { - console.log(`AI Moderation: Skipping low-risk pattern: "${content}"`); - return; } if (content.length <= 20 && /^[a-zA-Z]+$/.test(content)) if (SAFE_WORDS.has(content.toLowerCase())) { - console.log(`AI Moderation: Skipping safe word: "${content}"`); - return; } } @@ -114,10 +90,6 @@ export const handleAIModeration = (client: Client) => { } try { - console.log( - `AI Moderation: Analyzing message from ${message.author.username} in #${"name" in message.channel ? message.channel.name : "Unknown"}`, - ); - const context = await fetchMessageContext( message.channel as TextChannel | ThreadChannel, message.id, @@ -125,26 +97,21 @@ export const handleAIModeration = (client: Client) => { const analysis = await analyzeMessageWithAI(message, context); if (!analysis) { - console.log("AI analysis failed, skipping moderation"); - + console.error("AI analysis failed, skipping moderation"); return; } if (!analysis.violation) { - console.log( - `AI Moderation: No violation detected (confidence: ${analysis.confidence}%)`, - ); - return; } - console.log( - `AI Moderation: Violation detected - ${analysis.rule} (severity: ${analysis.severity}, confidence: ${analysis.confidence}%)`, + console.warn( + `Rule violation detected: ${analysis.rule} (severity: ${analysis.severity}, confidence: ${analysis.confidence}%)`, ); if (SKIP_ACTION) { - console.log( - `AI Moderation: SKIP_ACTION enabled - logging violation without taking action (severity: ${analysis.severity}, confidence: ${analysis.confidence}%)`, + console.warn( + `SKIP_ACTION enabled - logging violation without taking action (severity: ${analysis.severity}, confidence: ${analysis.confidence}%)`, ); } else if ( (analysis.severity === "critical" || analysis.severity === "high") && @@ -152,7 +119,7 @@ export const handleAIModeration = (client: Client) => { ) { try { await message.delete(); - console.log(`AI Moderation: Auto-deleted high severity violation`); + console.warn(`Auto-deleted high severity violation`); try { const notificationText = `${message.author}, your message was deleted: **${analysis.brief}**. This notification will be deleted in 10 seconds.\n\nIf you believe this was a mistake, let me know in #umabot.`; @@ -174,8 +141,8 @@ export const handleAIModeration = (client: Client) => { console.error("Failed to delete message:", error); } } else { - console.log( - `AI Moderation: Logging violation for human review (severity: ${analysis.severity}, confidence: ${analysis.confidence}%)`, + console.warn( + `Logging violation for human review (severity: ${analysis.severity}, confidence: ${analysis.confidence}%)`, ); } diff --git a/packages/gateway/src/listeners/moderationAgent/utilities.ts b/packages/gateway/src/listeners/moderationAgent/utilities.ts index cbf99f8..3e94e71 100644 --- a/packages/gateway/src/listeners/moderationAgent/utilities.ts +++ b/packages/gateway/src/listeners/moderationAgent/utilities.ts @@ -324,16 +324,6 @@ Remember: Only enforce the exact rules provided. Do not make assumptions or inte const data = await response.json(); - console.log("OpenRouter API response:", JSON.stringify(data, null, 2)); - - if (data.usage) - console.log("Token usage:", { - prompt_tokens: data.usage.prompt_tokens, - completion_tokens: data.usage.completion_tokens, - reasoning_tokens: - data.usage.completion_tokens_details?.reasoning_tokens || 0, - total_tokens: data.usage.total_tokens, - }); const content = data.choices[0]?.message?.content; diff --git a/packages/gateway/src/listeners/roleProtection.ts b/packages/gateway/src/listeners/roleProtection.ts index ff6ee38..fec8b8c 100644 --- a/packages/gateway/src/listeners/roleProtection.ts +++ b/packages/gateway/src/listeners/roleProtection.ts @@ -76,15 +76,11 @@ export const handleRoleProtection = (client: Client) => { ); if (relevantLog && relevantLog.executor?.id === guildOwner.id) { - console.log( - `High role ${role.name} (${role.id}) added to ${newMember.user.tag} by server owner, allowing...`, - ); - continue; } - console.log( - `High role ${role.name} (${role.id}) added to ${newMember.user.tag} (${newMember.id}) by unauthorized user, removing...`, + console.warn( + `Unauthorized high role assignment: ${role.name} (${role.id}) to ${newMember.user.tag} (${newMember.id})`, ); try { @@ -97,8 +93,8 @@ export const handleRoleProtection = (client: Client) => { } } catch (auditError) { console.error("Error checking audit log:", auditError); - console.log( - `High role ${role.name} (${role.id}) added to ${newMember.user.tag} (${newMember.id}), removing due to audit log error...`, + console.warn( + `High role ${role.name} (${role.id}) added to ${newMember.user.tag} (${newMember.id}), removing due to audit log error`, ); try { |