summaryrefslogtreecommitdiff
path: root/packages/gateway/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-09-26 23:30:44 -0700
committerFuwn <[email protected]>2025-09-26 23:30:44 -0700
commit6051cdb9b211fc02c919da4f33b64a50c87cb705 (patch)
tree037120264cd9eadfeda942b8dd9a5c4318a774f8 /packages/gateway/src
parentfeat(interactions): Rename roleplay verification slash command (diff)
downloadumabotdiscord-6051cdb9b211fc02c919da4f33b64a50c87cb705.tar.xz
umabotdiscord-6051cdb9b211fc02c919da4f33b64a50c87cb705.zip
feat(gateway:moderationAgent): Update agent context
Diffstat (limited to 'packages/gateway/src')
-rw-r--r--packages/gateway/src/listeners/moderationAgent/constants.ts2
-rw-r--r--packages/gateway/src/listeners/moderationAgent/utilities.ts18
2 files changed, 19 insertions, 1 deletions
diff --git a/packages/gateway/src/listeners/moderationAgent/constants.ts b/packages/gateway/src/listeners/moderationAgent/constants.ts
index b33f1b5..d01e751 100644
--- a/packages/gateway/src/listeners/moderationAgent/constants.ts
+++ b/packages/gateway/src/listeners/moderationAgent/constants.ts
@@ -7,7 +7,7 @@ export const MODERATION_LOG_CHANNEL_ID = "1406422619934167106";
export const MIN_MESSAGE_LENGTH = 15;
export const MAX_SYMBOL_DENSITY = 0.6;
export const MAX_COMPLETION_TOKENS = 2000;
-export const MESSAGE_HISTORY_SIZE = 0;
+export const MESSAGE_HISTORY_SIZE = 3;
export const MODEL = "mistralai/mistral-nemo";
export const SAFE_WORDS = new Set([
"hello",
diff --git a/packages/gateway/src/listeners/moderationAgent/utilities.ts b/packages/gateway/src/listeners/moderationAgent/utilities.ts
index d2d0a06..aa0cbbc 100644
--- a/packages/gateway/src/listeners/moderationAgent/utilities.ts
+++ b/packages/gateway/src/listeners/moderationAgent/utilities.ts
@@ -77,6 +77,15 @@ export const analyzeMessageWithAI = async (
const member = guild?.members.cache.get(authorId);
const authorRoles = member?.roles.cache.map(role => role.name).join(', ') || 'No roles';
const authorJoinedAt = member?.joinedAt?.toISOString() || 'Unknown';
+ let repliedToMessage = null;
+
+ if (message.reference && message.reference.messageId)
+ try {
+ repliedToMessage = await message.channel.messages.fetch(message.reference.messageId);
+ } catch (error) {
+ console.error("Error fetching replied-to message:", error);
+ }
+
const fullContext = `
=== SERVER CONTEXT ===
Server: ${guildName} (ID: ${guildId})
@@ -92,6 +101,14 @@ Timestamp: ${message.createdAt.toISOString()}
Length: ${messageLength} characters
Has Attachments: ${hasAttachments} (${message.attachments.size} files)
Has Embeds: ${hasEmbeds} (${message.embeds.length} embeds)
+${repliedToMessage ? `Is Reply: Yes (replying to message from ${repliedToMessage.author.username})` : 'Is Reply: No'}
+
+${repliedToMessage ? `=== REPLIED-TO MESSAGE ===
+Replied-to Author: ${repliedToMessage.author.username}
+Replied-to Message ID: ${repliedToMessage.id}
+Replied-to Timestamp: ${repliedToMessage.createdAt.toISOString()}
+Replied-to Content: "${repliedToMessage.content || '[No text content]'}"
+` : ''}
=== AUTHOR CONTEXT ===
Username: ${author.username}
@@ -201,6 +218,7 @@ ANALYSIS GUIDELINES:
- Read the SERVER_RULES section carefully and only enforce those specific rules
- Consider the channel context (NSFW vs SFW, channel purpose, etc.)
- Look at the message history for additional context
+- If this is a reply, consider the replied-to message context for better understanding
- Be aware of the author's roles and server tenure
- Consider cultural context and intent, not just literal text
- Distinguish between serious violations and casual/joking content