mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 15:15:02 +00:00
feat: polls
update DJS version, add new permissions, and add `match_polls` option
This commit is contained in:
parent
b28ca170ed
commit
4252cb5ce0
10 changed files with 150 additions and 101 deletions
|
@ -119,6 +119,16 @@ export class GuildSavedMessages extends BaseGuildRepository<SavedMessage> {
|
|||
}));
|
||||
}
|
||||
|
||||
if (msg.poll) {
|
||||
data.poll = {
|
||||
answers: Array.from(msg.poll.answers.values()).map((answer) => ({
|
||||
id: answer.id,
|
||||
text: answer.text,
|
||||
})),
|
||||
question: msg.poll.question,
|
||||
};
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,16 @@ export interface ISavedMessageStickerData {
|
|||
type: StickerType | null;
|
||||
}
|
||||
|
||||
export interface ISavedMessagePollData {
|
||||
answers: {
|
||||
id: number;
|
||||
text: string | null;
|
||||
}[];
|
||||
question: {
|
||||
text: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ISavedMessageData {
|
||||
attachments?: ISavedMessageAttachmentData[];
|
||||
author: {
|
||||
|
@ -73,6 +83,7 @@ export interface ISavedMessageData {
|
|||
content: string;
|
||||
embeds?: ISavedMessageEmbedData[];
|
||||
stickers?: ISavedMessageStickerData[];
|
||||
poll?: ISavedMessagePollData;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,17 @@ type TextTriggerWithMultipleMatchTypes = {
|
|||
match_usernames: boolean;
|
||||
match_nicknames: boolean;
|
||||
match_custom_status: boolean;
|
||||
match_polls: boolean;
|
||||
};
|
||||
|
||||
export type MatchableTextType = "message" | "embed" | "visiblename" | "username" | "nickname" | "customstatus";
|
||||
export type MatchableTextType =
|
||||
| "message"
|
||||
| "embed"
|
||||
| "visiblename"
|
||||
| "username"
|
||||
| "nickname"
|
||||
| "customstatus"
|
||||
| "polls";
|
||||
|
||||
type YieldedContent = [MatchableTextType, string];
|
||||
|
||||
|
@ -59,4 +67,8 @@ export async function* matchMultipleTextTypesOnMessage(
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (trigger.match_polls && msg.data.poll) {
|
||||
yield ["polls", JSON.stringify(msg.data.poll)];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ const configSchema = z.strictObject({
|
|||
match_usernames: z.boolean().default(false),
|
||||
match_nicknames: z.boolean().default(false),
|
||||
match_custom_status: z.boolean().default(false),
|
||||
match_polls: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const MatchInvitesTrigger = automodTrigger<MatchResultType>()({
|
||||
|
|
|
@ -47,6 +47,7 @@ const configSchema = z.strictObject({
|
|||
match_usernames: z.boolean().default(false),
|
||||
match_nicknames: z.boolean().default(false),
|
||||
match_custom_status: z.boolean().default(false),
|
||||
match_polls: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const MatchLinksTrigger = automodTrigger<MatchResultType>()({
|
||||
|
|
|
@ -24,6 +24,7 @@ const configSchema = z.strictObject({
|
|||
match_usernames: z.boolean().default(false),
|
||||
match_nicknames: z.boolean().default(false),
|
||||
match_custom_status: z.boolean().default(false),
|
||||
match_polls: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const regexCache = new WeakMap<any, RegExp[]>();
|
||||
|
|
|
@ -27,6 +27,7 @@ const configSchema = z.strictObject({
|
|||
match_usernames: z.boolean().default(false),
|
||||
match_nicknames: z.boolean().default(false),
|
||||
match_custom_status: z.boolean().default(false),
|
||||
match_polls: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
||||
|
@ -65,6 +66,8 @@ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
|||
str = normalizeText(str);
|
||||
}
|
||||
|
||||
console.log([type, str]);
|
||||
|
||||
for (const regex of regexes) {
|
||||
if (regex.test(str)) {
|
||||
return {
|
||||
|
|
|
@ -48,4 +48,8 @@ export const PERMISSION_NAMES = {
|
|||
UseExternalSounds: "Use External Sounds",
|
||||
UseSoundboard: "Use Soundboard",
|
||||
ViewCreatorMonetizationAnalytics: "View Creator Monetization Analytics",
|
||||
SendPolls: "Allows Sending Polls",
|
||||
CreateEvents: "Allows for creating scheduled events, and editing and deleting those created by the current user.",
|
||||
CreateGuildExpressions:
|
||||
"Allows for creating emojis, stickers, and soundboard sounds, and editing and deleting those created by the current user.",
|
||||
} as const satisfies Record<keyof typeof PermissionFlagsBits, string>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue