This commit is contained in:
ITOH
2021-04-06 21:40:03 +02:00
parent 484e995140
commit 59633b8ed6
3 changed files with 27 additions and 50 deletions
@@ -1,28 +1,17 @@
import { eventHandlers } from "../../bot.ts"; import { eventHandlers } from "../../bot.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import {
DiscordIntegrationCreateUpdate,
IntegrationCreateUpdate,
} from "../../types/integration/integration_create_update.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
export function handleIntegrationCreate( export function handleIntegrationCreate(
data: DiscordGatewayPayload, data: DiscordGatewayPayload,
) { ) {
const { const payload = data.d as DiscordIntegrationCreateUpdate;
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?.({ eventHandlers.integrationCreate?.(
...rest, snakeKeysToCamelCase(payload) as IntegrationCreateUpdate,
guildId, );
enableEmoticons,
expireBehavior,
expireGracePeriod,
syncedAt,
subscriberCount,
roleId,
});
} }
@@ -1,16 +1,15 @@
import { eventHandlers } from "../../bot.ts"; import { eventHandlers } from "../../bot.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import {
DiscordIntegrationDelete,
IntegrationDelete,
} from "../../types/integration/integration_delete.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
export function handleIntegrationDelete(data: DiscordGatewayPayload) { export function handleIntegrationDelete(data: DiscordGatewayPayload) {
const { const payload = data.d as DiscordIntegrationDelete;
guild_id: guildId,
application_id: applicationId,
...rest
} = data.d as IntegrationDeleteEvent;
eventHandlers.integrationDelete?.({ eventHandlers.integrationDelete?.(
...rest, snakeKeysToCamelCase(payload) as IntegrationDelete,
applicationId, );
guildId,
});
} }
@@ -1,26 +1,15 @@
import { eventHandlers } from "../../bot.ts"; import { eventHandlers } from "../../bot.ts";
import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts"; import { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import {
DiscordIntegrationCreateUpdate,
IntegrationCreateUpdate,
} from "../../types/integration/integration_create_update.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
export function handleIntegrationUpdate(data: DiscordGatewayPayload) { export function handleIntegrationUpdate(data: DiscordGatewayPayload) {
const { const payload = data.d as DiscordIntegrationCreateUpdate;
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?.({ eventHandlers.integrationUpdate?.(
...rest, snakeKeysToCamelCase(payload) as IntegrationCreateUpdate,
guildId, );
subscriberCount,
enableEmoticons,
expireGracePeriod,
roleId,
expireBehavior,
syncedAt,
});
} }