diff --git a/backend/src/data/GuildSavedMessages.ts b/backend/src/data/GuildSavedMessages.ts index dd097b4e..008b9e9b 100644 --- a/backend/src/data/GuildSavedMessages.ts +++ b/backend/src/data/GuildSavedMessages.ts @@ -121,11 +121,11 @@ export class GuildSavedMessages extends BaseGuildRepository { if (msg.poll) { data.poll = { + question: msg.poll.question, answers: Array.from(msg.poll.answers.values()).map((answer) => ({ id: answer.id, text: answer.text, })), - question: msg.poll.question, }; } diff --git a/backend/src/data/entities/SavedMessage.ts b/backend/src/data/entities/SavedMessage.ts index 5e4bf103..78856e7f 100644 --- a/backend/src/data/entities/SavedMessage.ts +++ b/backend/src/data/entities/SavedMessage.ts @@ -65,13 +65,13 @@ export interface ISavedMessageStickerData { } export interface ISavedMessagePollData { + question: { + text: string; + }; answers: { id: number; text: string | null; }[]; - question: { - text: string; - }; } export interface ISavedMessageData { diff --git a/backend/src/plugins/Automod/functions/getTextMatchPartialSummary.ts b/backend/src/plugins/Automod/functions/getTextMatchPartialSummary.ts index 3d7e993f..34b0fc75 100644 --- a/backend/src/plugins/Automod/functions/getTextMatchPartialSummary.ts +++ b/backend/src/plugins/Automod/functions/getTextMatchPartialSummary.ts @@ -30,5 +30,10 @@ export function getTextMatchPartialSummary( return `visible name: ${visibleName}`; } else if (type === "customstatus") { return `custom status: ${context.member!.presence?.activities.find((a) => a.type === ActivityType.Custom)?.name}`; + } else if (type == "poll") { + const message = context.message!; + const channel = pluginData.guild.channels.cache.get(message.channel_id as Snowflake); + const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``; + return `poll in ${channelMention}:\n${messageSummary(message)}`; } } diff --git a/backend/src/plugins/Automod/functions/matchMultipleTextTypesOnMessage.ts b/backend/src/plugins/Automod/functions/matchMultipleTextTypesOnMessage.ts index 92fd572d..a271516f 100644 --- a/backend/src/plugins/Automod/functions/matchMultipleTextTypesOnMessage.ts +++ b/backend/src/plugins/Automod/functions/matchMultipleTextTypesOnMessage.ts @@ -15,14 +15,7 @@ type TextTriggerWithMultipleMatchTypes = { match_polls: boolean; }; -export type MatchableTextType = - | "message" - | "embed" - | "visiblename" - | "username" - | "nickname" - | "customstatus" - | "polls"; +export type MatchableTextType = "message" | "embed" | "visiblename" | "username" | "nickname" | "customstatus" | "poll"; type YieldedContent = [MatchableTextType, string]; @@ -69,6 +62,6 @@ export async function* matchMultipleTextTypesOnMessage( } if (trigger.match_polls && msg.data.poll) { - yield ["polls", JSON.stringify(msg.data.poll)]; + yield ["poll", JSON.stringify(msg.data.poll)]; } } diff --git a/backend/src/utils.ts b/backend/src/utils.ts index 174a720f..2e2d5ca3 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -1326,6 +1326,10 @@ export function messageSummary(msg: SavedMessage) { "\n"; } + if (msg.data.poll) { + result += "Poll: ```" + escapeCodeBlock(JSON.stringify(msg.data.poll)) + "```"; + } + return result; }