mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 18:00:08 +00:00
feat(controllers): add INTEGRATION* gateway events (#459)
* feat(controllers): add INTEGRATION* gateway events * suggestions * forgive me, i am forgetful :P * Update src/types/options.ts Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { eventHandlers, setApplicationID, setBotID } from "../../bot.ts";
|
||||
import {
|
||||
DiscordPayload,
|
||||
IntegrationCreateUpdateEvent,
|
||||
IntegrationDeleteEvent,
|
||||
PresenceUpdatePayload,
|
||||
ReadyPayload,
|
||||
TypingStartPayload,
|
||||
@@ -155,3 +157,73 @@ export function handleInternalWebhooksUpdate(data: DiscordPayload) {
|
||||
options.guild_id,
|
||||
);
|
||||
}
|
||||
|
||||
export function handleInternalIntegrationCreate(
|
||||
data: DiscordPayload,
|
||||
) {
|
||||
if (data.t !== "INTEGRATION_CREATE") return;
|
||||
|
||||
const {
|
||||
guild_id: guildID,
|
||||
enable_emoticons: enableEmoticons,
|
||||
expire_behavior: expireBehavior,
|
||||
expire_grace_period: expireGracePeriod,
|
||||
subscriber_count: subscriberCount,
|
||||
role_id: roleID,
|
||||
synced_at: syncedAt,
|
||||
...rest
|
||||
} = data.d as IntegrationCreateUpdateEvent;
|
||||
|
||||
eventHandlers.integrationCreate?.({
|
||||
...rest,
|
||||
guildID,
|
||||
enableEmoticons,
|
||||
expireBehavior,
|
||||
expireGracePeriod,
|
||||
syncedAt,
|
||||
subscriberCount,
|
||||
roleID,
|
||||
});
|
||||
}
|
||||
|
||||
export function handleInternalIntegrationUpdate(data: DiscordPayload) {
|
||||
if (data.t !== "INTEGRATION_UPDATE") return;
|
||||
|
||||
const {
|
||||
enable_emoticons: enableEmoticons,
|
||||
expire_behavior: expireBehavior,
|
||||
expire_grace_period: expireGracePeriod,
|
||||
role_id: roleID,
|
||||
subscriber_count: subscriberCount,
|
||||
synced_at: syncedAt,
|
||||
guild_id: guildID,
|
||||
...rest
|
||||
} = data.d as IntegrationCreateUpdateEvent;
|
||||
|
||||
eventHandlers.integrationUpdate?.({
|
||||
...rest,
|
||||
guildID,
|
||||
subscriberCount,
|
||||
enableEmoticons,
|
||||
expireGracePeriod,
|
||||
roleID,
|
||||
expireBehavior,
|
||||
syncedAt,
|
||||
});
|
||||
}
|
||||
|
||||
export function handleInternalIntegrationDelete(data: DiscordPayload) {
|
||||
if (data.t !== "INTEGRATION_DELETE") return;
|
||||
|
||||
const {
|
||||
guild_id: guildID,
|
||||
application_id: applicationID,
|
||||
...rest
|
||||
} = data.d as IntegrationDeleteEvent;
|
||||
|
||||
eventHandlers.integrationDelete?.({
|
||||
...rest,
|
||||
applicationID,
|
||||
guildID,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ import {
|
||||
handleInternalMessageUpdate,
|
||||
} from "./messages.ts";
|
||||
import {
|
||||
handleInternalIntegrationCreate,
|
||||
handleInternalIntegrationDelete,
|
||||
handleInternalIntegrationUpdate,
|
||||
handleInternalPresenceUpdate,
|
||||
handleInternalReady,
|
||||
handleInternalTypingStart,
|
||||
@@ -82,6 +85,9 @@ export let controllers = {
|
||||
USER_UPDATE: handleInternalUserUpdate,
|
||||
VOICE_STATE_UPDATE: handleInternalVoiceStateUpdate,
|
||||
WEBHOOKS_UPDATE: handleInternalWebhooksUpdate,
|
||||
INTEGRATION_CREATE: handleInternalIntegrationCreate,
|
||||
INTEGRATION_UPDATE: handleInternalIntegrationUpdate,
|
||||
INTEGRATION_DELETE: handleInternalIntegrationDelete,
|
||||
};
|
||||
|
||||
export type Controllers = typeof controllers;
|
||||
|
||||
Reference in New Issue
Block a user