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 { 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(
data: DiscordGatewayPayload,
) {
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;
const payload = data.d as DiscordIntegrationCreateUpdate;
eventHandlers.integrationCreate?.({
...rest,
guildId,
enableEmoticons,
expireBehavior,
expireGracePeriod,
syncedAt,
subscriberCount,
roleId,
});
eventHandlers.integrationCreate?.(
snakeKeysToCamelCase(payload) as IntegrationCreateUpdate,
);
}