mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
Merge branch 'main' into builders
This commit is contained in:
commit
9ddd9492a3
@ -26,6 +26,9 @@ import type {
|
|||||||
DiscordThreadListSync,
|
DiscordThreadListSync,
|
||||||
DiscordUser,
|
DiscordUser,
|
||||||
DiscordWebhookUpdate,
|
DiscordWebhookUpdate,
|
||||||
|
DiscordIntegration,
|
||||||
|
DiscordIntegrationDelete
|
||||||
|
|
||||||
} from "../vendor/external.ts";
|
} from "../vendor/external.ts";
|
||||||
import type { Snowflake } from "../util/Snowflake.ts";
|
import type { Snowflake } from "../util/Snowflake.ts";
|
||||||
import type { Session } from "../session/Session.ts";
|
import type { Session } from "../session/Session.ts";
|
||||||
@ -39,6 +42,7 @@ import Message from "../structures/Message.ts";
|
|||||||
import User from "../structures/User.ts";
|
import User from "../structures/User.ts";
|
||||||
import Guild from "../structures/guilds/Guild.ts";
|
import Guild from "../structures/guilds/Guild.ts";
|
||||||
import Interaction from "../structures/interactions/Interaction.ts";
|
import Interaction from "../structures/interactions/Interaction.ts";
|
||||||
|
import { Integration } from "../structures/Integration.ts"
|
||||||
|
|
||||||
export type RawHandler<T> = (...args: [Session, number, T]) => void;
|
export type RawHandler<T> = (...args: [Session, number, T]) => void;
|
||||||
export type Handler<T extends unknown[]> = (...args: T) => unknown;
|
export type Handler<T extends unknown[]> = (...args: T) => unknown;
|
||||||
@ -167,6 +171,18 @@ export const WEBHOOKS_UPDATE: RawHandler<DiscordWebhookUpdate> = (session, _shar
|
|||||||
session.emit("webhooksUpdate", { guildId: webhook.guild_id, channelId: webhook.channel_id });
|
session.emit("webhooksUpdate", { guildId: webhook.guild_id, channelId: webhook.channel_id });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const INTEGRATION_CREATE: RawHandler<DiscordIntegration> = (session, _shardId, payload) => {
|
||||||
|
session.emit("integrationCreate", new Integration(session, payload));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const INTEGRATION_UPDATE: RawHandler<DiscordIntegration> = (session, _shardId, payload) => {
|
||||||
|
session.emit("integrationCreate", new Integration(session, payload));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const INTEGRATION_DELETE: RawHandler<DiscordIntegrationDelete> = (session, _shardId, payload) => {
|
||||||
|
session.emit("integrationDelete", { id: payload.id, guildId: payload.guild_id, applicationId: payload.application_id });
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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);
|
||||||
@ -226,6 +242,9 @@ export interface Events {
|
|||||||
"threadDelete": Handler<[ThreadChannel]>;
|
"threadDelete": Handler<[ThreadChannel]>;
|
||||||
"threadListSync": Handler<[{ guildId: Snowflake, channelIds: Snowflake[], threads: ThreadChannel[], members: ThreadMember[] }]>
|
"threadListSync": Handler<[{ guildId: Snowflake, channelIds: Snowflake[], threads: ThreadChannel[], members: ThreadMember[] }]>
|
||||||
"interactionCreate": Handler<[Interaction]>;
|
"interactionCreate": Handler<[Interaction]>;
|
||||||
|
"integrationCreate": Handler<[DiscordIntegration]>;
|
||||||
|
"integrationUpdate": Handler<[DiscordIntegration]>;
|
||||||
|
"integrationDelete": Handler<[{ id: Snowflake, guildId?: Snowflake, applicationId?: Snowflake }]>;
|
||||||
"raw": Handler<[unknown, number]>;
|
"raw": Handler<[unknown, number]>;
|
||||||
"webhooksUpdate": Handler<[{ guildId: Snowflake, channelId: Snowflake }]>;
|
"webhooksUpdate": Handler<[{ guildId: Snowflake, channelId: Snowflake }]>;
|
||||||
}
|
}
|
||||||
|
55
structures/Integration.ts
Normal file
55
structures/Integration.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import type { Model } from "./Base.ts";
|
||||||
|
import type { Snowflake } from "../util/Snowflake.ts";
|
||||||
|
import type { Session } from "../session/Session.ts";
|
||||||
|
import type {
|
||||||
|
DiscordIntegration,
|
||||||
|
DiscordIntegrationAccount,
|
||||||
|
DiscordIntegrationApplication,
|
||||||
|
DiscordUser,
|
||||||
|
IntegrationExpireBehaviors
|
||||||
|
} from "../vendor/external.ts";
|
||||||
|
|
||||||
|
export class Integration implements Model {
|
||||||
|
constructor(session: Session, data: DiscordIntegration & { guild_id?: Snowflake }) {
|
||||||
|
this.id = data.id;
|
||||||
|
this.session = session;
|
||||||
|
|
||||||
|
data.guild_id ? this.guildId = data.guild_id : null;
|
||||||
|
|
||||||
|
this.name = data.name;
|
||||||
|
this.type = data.type;
|
||||||
|
this.enabled = !!data.enabled;
|
||||||
|
this.syncing = !!data.syncing;
|
||||||
|
this.roleId = data.role_id;
|
||||||
|
this.enableEmoticons = !!data.enable_emoticons;
|
||||||
|
this.expireBehavior = data.expire_behavior;
|
||||||
|
this.expireGracePeriod = data.expire_grace_period;
|
||||||
|
this.syncedAt = data.synced_at;
|
||||||
|
this.subscriberCount = data.subscriber_count;
|
||||||
|
this.revoked = !!data.revoked;
|
||||||
|
|
||||||
|
this.user = data.user;
|
||||||
|
this.account = data.account;
|
||||||
|
this.application = data.application;
|
||||||
|
}
|
||||||
|
|
||||||
|
id: Snowflake;
|
||||||
|
session: Session;
|
||||||
|
guildId?: Snowflake;
|
||||||
|
|
||||||
|
name: string
|
||||||
|
type: "twitch" | "youtube" | "discord";
|
||||||
|
enabled?: boolean;
|
||||||
|
syncing?: boolean;
|
||||||
|
roleId?: string;
|
||||||
|
enableEmoticons?: boolean;
|
||||||
|
expireBehavior?: IntegrationExpireBehaviors;
|
||||||
|
expireGracePeriod?: number;
|
||||||
|
syncedAt?: string;
|
||||||
|
subscriberCount?: number;
|
||||||
|
revoked?: boolean;
|
||||||
|
|
||||||
|
user?: DiscordUser;
|
||||||
|
account: DiscordIntegrationAccount;
|
||||||
|
application?: DiscordIntegrationApplication;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user