Skip to content

Commit 83721c1

Browse files
committed
fix: partial summary
1 parent 0bcd727 commit 83721c1

5 files changed

Lines changed: 15 additions & 13 deletions

File tree

backend/src/data/GuildSavedMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ export class GuildSavedMessages extends BaseGuildRepository<SavedMessage> {
121121

122122
if (msg.poll) {
123123
data.poll = {
124+
question: msg.poll.question,
124125
answers: Array.from(msg.poll.answers.values()).map((answer) => ({
125126
id: answer.id,
126127
text: answer.text,
127128
})),
128-
question: msg.poll.question,
129129
};
130130
}
131131

backend/src/data/entities/SavedMessage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ export interface ISavedMessageStickerData {
6565
}
6666

6767
export interface ISavedMessagePollData {
68+
question: {
69+
text: string;
70+
};
6871
answers: {
6972
id: number;
7073
text: string | null;
7174
}[];
72-
question: {
73-
text: string;
74-
};
7575
}
7676

7777
export interface ISavedMessageData {

backend/src/plugins/Automod/functions/getTextMatchPartialSummary.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,10 @@ export function getTextMatchPartialSummary(
3030
return `visible name: ${visibleName}`;
3131
} else if (type === "customstatus") {
3232
return `custom status: ${context.member!.presence?.activities.find((a) => a.type === ActivityType.Custom)?.name}`;
33+
} else if (type == "poll") {
34+
const message = context.message!;
35+
const channel = pluginData.guild.channels.cache.get(message.channel_id as Snowflake);
36+
const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``;
37+
return `poll in ${channelMention}:\n${messageSummary(message)}`;
3338
}
3439
}

backend/src/plugins/Automod/functions/matchMultipleTextTypesOnMessage.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@ type TextTriggerWithMultipleMatchTypes = {
1515
match_polls: boolean;
1616
};
1717

18-
export type MatchableTextType =
19-
| "message"
20-
| "embed"
21-
| "visiblename"
22-
| "username"
23-
| "nickname"
24-
| "customstatus"
25-
| "polls";
18+
export type MatchableTextType = "message" | "embed" | "visiblename" | "username" | "nickname" | "customstatus" | "poll";
2619

2720
type YieldedContent = [MatchableTextType, string];
2821

@@ -69,6 +62,6 @@ export async function* matchMultipleTextTypesOnMessage(
6962
}
7063

7164
if (trigger.match_polls && msg.data.poll) {
72-
yield ["polls", JSON.stringify(msg.data.poll)];
65+
yield ["poll", JSON.stringify(msg.data.poll)];
7366
}
7467
}

backend/src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,10 @@ export function messageSummary(msg: SavedMessage) {
13261326
"\n";
13271327
}
13281328

1329+
if (msg.data.poll) {
1330+
result += "Poll: ```" + escapeCodeBlock(JSON.stringify(msg.data.poll)) + "```";
1331+
}
1332+
13291333
return result;
13301334
}
13311335

0 commit comments

Comments
 (0)