Skip to content

Commit

Permalink
fix mismatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
azep-ninja committed Dec 16, 2024
1 parent b04fe69 commit 4ec2657
Showing 1 changed file with 21 additions and 41 deletions.
62 changes: 21 additions & 41 deletions packages/client-discord/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,27 @@ export class MessageManager {
}
}

private _isMessageForMe(message: DiscordMessage): boolean {
const isMentioned = message.mentions.users?.has(this.client.user?.id as string);
const guild = message.guild;
const member = guild?.members.cache.get(this.client.user?.id as string);
const nickname = member?.nickname;
const memberId = member?.id;

// Don't consider role mentions as direct mentions
const hasRoleMentionOnly = message.mentions.roles.size > 0 && !isMentioned;

// If it's only a role mention and we're in team mode, let team logic handle it
if (hasRoleMentionOnly && this.runtime.character.clientConfig?.discord?.isPartOfTeam) {
return false;
}

return isMentioned || (!this.runtime.character.clientConfig?.discord?.shouldRespondOnlyToMentions && (
message.content.toLowerCase().includes(this.client.user?.username.toLowerCase() as string) ||
message.content.toLowerCase().includes(this.client.user?.tag.toLowerCase() as string) ||
(nickname && message.content.toLowerCase().includes(nickname.toLowerCase()))));
}

async processMessageMedia(
message: DiscordMessage
): Promise<{ processedContent: string; attachments: Media[] }> {
Expand Down Expand Up @@ -666,47 +687,6 @@ export class MessageManager {
);
}

private _isMessageForMe(message: DiscordMessage): boolean {
const isMentioned = message.mentions.users?.has(
this.client.user?.id as string
);
const guild = message.guild;
const member = guild?.members.cache.get(this.client.user?.id as string);
const nickname = member?.nickname;

// Don't consider role mentions as direct mentions
const hasRoleMentionOnly =
message.mentions.roles.size > 0 && !isMentioned;

// If it's only a role mention and we're in team mode, let team logic handle it
if (
hasRoleMentionOnly &&
this.runtime.character.clientConfig?.discord?.isPartOfTeam
) {
return false;
}

return (
isMentioned ||
(!this.runtime.character.clientConfig?.discord
?.shouldRespondOnlyToMentions &&
(message.content
.toLowerCase()
.includes(
this.client.user?.username.toLowerCase() as string
) ||
message.content
.toLowerCase()
.includes(
this.client.user?.tag.toLowerCase() as string
) ||
(nickname &&
message.content
.toLowerCase()
.includes(nickname.toLowerCase()))))
);
}

private async _analyzeContextSimilarity(
currentMessage: string,
previousContext?: MessageContext,
Expand Down

0 comments on commit 4ec2657

Please sign in to comment.