mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
parent
9cd9d307c5
commit
77929f8e6b
@ -1,4 +1,6 @@
|
|||||||
import type {
|
import type {
|
||||||
|
DiscordAutoModerationActionExecution,
|
||||||
|
DiscordAutoModerationRule,
|
||||||
DiscordChannel,
|
DiscordChannel,
|
||||||
DiscordChannelPinsUpdate,
|
DiscordChannelPinsUpdate,
|
||||||
DiscordEmoji,
|
DiscordEmoji,
|
||||||
@ -33,10 +35,12 @@ import type {
|
|||||||
|
|
||||||
import type { Snowflake } from "./Snowflake.ts";
|
import type { Snowflake } from "./Snowflake.ts";
|
||||||
import type { Session } from "./Session.ts";
|
import type { Session } from "./Session.ts";
|
||||||
import type { Channel } from "./structures/channels.ts";
|
|
||||||
import type { Interaction } from "./structures/interactions/InteractionFactory.ts";
|
import type { Interaction } from "./structures/interactions/InteractionFactory.ts";
|
||||||
|
|
||||||
import { ChannelFactory, GuildChannel, ThreadChannel } from "./structures/channels.ts";
|
|
||||||
|
import { AutoModerationRule } from "./structures/AutoModerationRule.ts";
|
||||||
|
import { AutoModerationExecution } from "./structures/AutoModerationExecution.ts";
|
||||||
|
import { type Channel, ChannelFactory, GuildChannel, ThreadChannel } from "./structures/channels.ts";
|
||||||
|
|
||||||
import ThreadMember from "./structures/ThreadMember.ts";
|
import ThreadMember from "./structures/ThreadMember.ts";
|
||||||
import Member from "./structures/Member.ts";
|
import Member from "./structures/Member.ts";
|
||||||
@ -227,6 +231,26 @@ export const INTEGRATION_DELETE: RawHandler<DiscordIntegrationDelete> = (session
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const AUTO_MODERATION_RULE_CREATE: RawHandler<DiscordAutoModerationRule> = (session, _shardId, payload) => {
|
||||||
|
session.emit("autoModerationRuleCreate", new AutoModerationRule(session, payload));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AUTO_MODERATION_RULE_UPDATE: RawHandler<DiscordAutoModerationRule> = (session, _shardId, payload) => {
|
||||||
|
session.emit("autoModerationRuleUpdate", new AutoModerationRule(session, payload));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AUTO_MODERATION_RULE_DELETE: RawHandler<DiscordAutoModerationRule> = (session, _shardId, payload) => {
|
||||||
|
session.emit("autoModerationRuleDelete", new AutoModerationRule(session, payload));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AUTO_MODERATION_ACTION_EXECUTE: RawHandler<DiscordAutoModerationActionExecution> = (
|
||||||
|
session,
|
||||||
|
_shardId,
|
||||||
|
payload,
|
||||||
|
) => {
|
||||||
|
session.emit("autoModerationActionExecution", new AutoModerationExecution(session, payload));
|
||||||
|
};
|
||||||
|
|
||||||
export const MESSAGE_REACTION_ADD: RawHandler<DiscordMessageReactionAdd> = (session, _shardId, reaction) => {
|
export const MESSAGE_REACTION_ADD: RawHandler<DiscordMessageReactionAdd> = (session, _shardId, reaction) => {
|
||||||
session.emit("messageReactionAdd", null);
|
session.emit("messageReactionAdd", null);
|
||||||
};
|
};
|
||||||
@ -296,6 +320,10 @@ export interface Events {
|
|||||||
"integrationCreate": Handler<[Integration]>;
|
"integrationCreate": Handler<[Integration]>;
|
||||||
"integrationUpdate": Handler<[Integration]>;
|
"integrationUpdate": Handler<[Integration]>;
|
||||||
"integrationDelete": Handler<[{ id: Snowflake, guildId?: Snowflake, applicationId?: Snowflake }]>;
|
"integrationDelete": Handler<[{ id: Snowflake, guildId?: Snowflake, applicationId?: Snowflake }]>;
|
||||||
|
"autoModerationRuleCreate": Handler<[AutoModerationRule]>;
|
||||||
|
"autoModerationRuleUpdate": Handler<[AutoModerationRule]>;
|
||||||
|
"autoModerationRuleDelete": Handler<[AutoModerationRule]>;
|
||||||
|
"autoModerationActionExecution":Handler<[AutoModerationExecution]>
|
||||||
"raw": Handler<[unknown, number]>;
|
"raw": Handler<[unknown, number]>;
|
||||||
"webhooksUpdate": Handler<[{ guildId: Snowflake, channelId: Snowflake }]>;
|
"webhooksUpdate": Handler<[{ guildId: Snowflake, channelId: Snowflake }]>;
|
||||||
"userUpdate": Handler<[User]>;
|
"userUpdate": Handler<[User]>;
|
||||||
|
51
packages/biscuit/structures/AutoModerationExecution.ts
Normal file
51
packages/biscuit/structures/AutoModerationExecution.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { AutoModerationTriggerTypes, DiscordAutoModerationActionExecution } from "../../discordeno/mod.ts";
|
||||||
|
import type { Session } from "../Session.ts";
|
||||||
|
import type { Snowflake } from "../Snowflake.ts";
|
||||||
|
import { AutoModerationAction } from "./AutoModerationRule.ts";
|
||||||
|
|
||||||
|
export class AutoModerationExecution {
|
||||||
|
constructor(session: Session, data: DiscordAutoModerationActionExecution) {
|
||||||
|
this.session = session;
|
||||||
|
this.guildId = data.guild_id;
|
||||||
|
this.action = Object.create({
|
||||||
|
type: data.action.type,
|
||||||
|
metadata: {
|
||||||
|
channelId: data.action.metadata.channel_id,
|
||||||
|
durationSeconds: data.action.metadata.duration_seconds,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.ruleId = data.rule_id;
|
||||||
|
this.ruleTriggerType = data.rule_trigger_type;
|
||||||
|
this.userId = data.user_id;
|
||||||
|
this.content = data.content;
|
||||||
|
if (data.channel_id) {
|
||||||
|
this.channelId = data.channel_id;
|
||||||
|
}
|
||||||
|
if (data.message_id) {
|
||||||
|
this.messageId = data.message_id;
|
||||||
|
}
|
||||||
|
if (data.alert_system_message_id) {
|
||||||
|
this.alertSystemMessageId = data.alert_system_message_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.matched_keyword) {
|
||||||
|
this.matchedKeyword = data.matched_keyword;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.matched_content) {
|
||||||
|
this.matched_content = data.matched_content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session: Session;
|
||||||
|
guildId: Snowflake;
|
||||||
|
action: AutoModerationAction;
|
||||||
|
ruleId: Snowflake;
|
||||||
|
ruleTriggerType: AutoModerationTriggerTypes;
|
||||||
|
userId: Snowflake;
|
||||||
|
channelId?: Snowflake;
|
||||||
|
messageId?: Snowflake;
|
||||||
|
alertSystemMessageId?: Snowflake;
|
||||||
|
content?: string;
|
||||||
|
matchedKeyword?: string;
|
||||||
|
matched_content?: string;
|
||||||
|
}
|
65
packages/biscuit/structures/AutoModerationRule.ts
Normal file
65
packages/biscuit/structures/AutoModerationRule.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import {
|
||||||
|
AutoModerationActionType,
|
||||||
|
AutoModerationEventTypes,
|
||||||
|
AutoModerationTriggerTypes,
|
||||||
|
DiscordAutoModerationRule,
|
||||||
|
DiscordAutoModerationRuleTriggerMetadataPresets,
|
||||||
|
} from "../../discordeno/mod.ts";
|
||||||
|
import { Model } from "./Base.ts";
|
||||||
|
import type { Session } from "../Session.ts";
|
||||||
|
import type { Snowflake } from "../Snowflake.ts";
|
||||||
|
|
||||||
|
export interface AutoModerationRuleTriggerMetadata {
|
||||||
|
keywordFilter?: string[];
|
||||||
|
presets?: DiscordAutoModerationRuleTriggerMetadataPresets[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActionMetadata {
|
||||||
|
channelId: Snowflake;
|
||||||
|
durationSeconds: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AutoModerationAction {
|
||||||
|
type: AutoModerationActionType;
|
||||||
|
metadata: ActionMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AutoModerationRule implements Model {
|
||||||
|
constructor(session: Session, data: DiscordAutoModerationRule) {
|
||||||
|
this.session = session;
|
||||||
|
this.id = data.id;
|
||||||
|
this.guildId = data.guild_id;
|
||||||
|
this.name = data.name;
|
||||||
|
this.creatorId = data.creator_id;
|
||||||
|
this.eventType = data.event_type;
|
||||||
|
this.triggerType = data.trigger_type;
|
||||||
|
this.triggerMetadata = {
|
||||||
|
keywordFilter: data.trigger_metadata.keyword_filter,
|
||||||
|
presets: data.trigger_metadata.presets,
|
||||||
|
};
|
||||||
|
this.actions = data.actions.map((action) =>
|
||||||
|
Object.create({
|
||||||
|
type: action.type,
|
||||||
|
metadata: {
|
||||||
|
channelId: action.metadata.channel_id,
|
||||||
|
durationSeconds: action.metadata.duration_seconds,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
this.enabled = !!data.enabled;
|
||||||
|
this.exemptRoles = data.exempt_roles;
|
||||||
|
this.exemptChannels = data.exempt_channels;
|
||||||
|
}
|
||||||
|
session: Session;
|
||||||
|
id: Snowflake;
|
||||||
|
guildId: Snowflake;
|
||||||
|
name: string;
|
||||||
|
creatorId: Snowflake;
|
||||||
|
eventType: AutoModerationEventTypes;
|
||||||
|
triggerType: AutoModerationTriggerTypes;
|
||||||
|
triggerMetadata: AutoModerationRuleTriggerMetadata;
|
||||||
|
actions: AutoModerationAction[];
|
||||||
|
enabled: boolean;
|
||||||
|
exemptRoles: Snowflake[];
|
||||||
|
exemptChannels: Snowflake[];
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user