mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
types: add gateway types
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import {
|
||||
DiscordApplicationCommandCreateUpdateDelete,
|
||||
DiscordGatewayPayload,
|
||||
} from "../../types/gateway.ts";
|
||||
|
||||
export function handleApplicationCommandCreate(
|
||||
data: DiscordPayload,
|
||||
data: DiscordGatewayPayload,
|
||||
) {
|
||||
const {
|
||||
guild_id: guildId,
|
||||
application_id: applicationId,
|
||||
...rest
|
||||
} = data.d as ApplicationCommandEvent;
|
||||
} = data.d as DiscordApplicationCommandCreateUpdateDelete;
|
||||
|
||||
eventHandlers.applicationCommandCreate?.({
|
||||
...rest,
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import {
|
||||
DiscordApplicationCommandCreateUpdateDelete,
|
||||
DiscordGatewayPayload,
|
||||
} from "../../types/gateway.ts";
|
||||
|
||||
export function handleApplicationCommandDelete(data: DiscordPayload) {
|
||||
export function handleApplicationCommandDelete(data: DiscordGatewayPayload) {
|
||||
const {
|
||||
application_id: applicationId,
|
||||
guild_id: guildId,
|
||||
...rest
|
||||
} = data.d as ApplicationCommandEvent;
|
||||
} = data.d as DiscordApplicationCommandCreateUpdateDelete;
|
||||
|
||||
eventHandlers.applicationCommandDelete?.({
|
||||
...rest,
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import {
|
||||
DiscordApplicationCommandCreateUpdateDelete,
|
||||
DiscordGatewayPayload,
|
||||
} from "../../types/gateway.ts";
|
||||
|
||||
export function handleApplicationCommandUpdate(data: DiscordPayload) {
|
||||
export function handleApplicationCommandUpdate(data: DiscordGatewayPayload) {
|
||||
const {
|
||||
application_id: applicationId,
|
||||
guild_id: guildId,
|
||||
...rest
|
||||
} = data.d as ApplicationCommandEvent;
|
||||
} = data.d as DiscordApplicationCommandCreateUpdateDelete;
|
||||
|
||||
eventHandlers.applicationCommandUpdate?.({
|
||||
...rest,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway.ts";
|
||||
|
||||
export function handleIntegrationCreate(
|
||||
data: DiscordPayload,
|
||||
data: DiscordGatewayPayload,
|
||||
) {
|
||||
const {
|
||||
guild_id: guildId,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway.ts";
|
||||
|
||||
export function handleIntegrationDelete(data: DiscordPayload) {
|
||||
export function handleIntegrationDelete(data: DiscordGatewayPayload) {
|
||||
const {
|
||||
guild_id: guildId,
|
||||
application_id: applicationId,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway.ts";
|
||||
|
||||
export function handleIntegrationUpdate(data: DiscordPayload) {
|
||||
export function handleIntegrationUpdate(data: DiscordGatewayPayload) {
|
||||
const {
|
||||
enable_emoticons: enableEmoticons,
|
||||
expire_behavior: expireBehavior,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway.ts";
|
||||
|
||||
export async function handleInteractionCreate(data: DiscordPayload) {
|
||||
export async function handleInteractionCreate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as InteractionCommandPayload;
|
||||
const memberStruct = await structures.createMemberStruct(
|
||||
payload.member,
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import {
|
||||
DiscordGatewayPayload,
|
||||
DiscordInviteCreate,
|
||||
} from "../../types/gateway.ts";
|
||||
|
||||
export function handleInviteCreate(payload: DiscordPayload) {
|
||||
if (payload.t !== "INVITE_CREATE") return;
|
||||
//TODO: replace with tocamelcase
|
||||
export function handleInviteCreate(payload: DiscordGatewayPayload) {
|
||||
// TODO: replace with tocamelcase
|
||||
const {
|
||||
channel_id: channelId,
|
||||
created_at: createdAt,
|
||||
@@ -12,7 +15,7 @@ export function handleInviteCreate(payload: DiscordPayload) {
|
||||
target_user_type: targetUserType,
|
||||
max_uses: maxUses,
|
||||
...rest
|
||||
} = payload.d as InviteCreateEvent;
|
||||
} = payload.d as DiscordInviteCreate;
|
||||
|
||||
eventHandlers.inviteCreate?.({
|
||||
...rest,
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import {
|
||||
DiscordGatewayPayload,
|
||||
DiscordInviteDelete,
|
||||
} from "../../types/gateway.ts";
|
||||
|
||||
export function handleInviteDelete(payload: DiscordPayload) {
|
||||
if (payload.t !== "INVITE_DELETE") return;
|
||||
|
||||
export function handleInviteDelete(payload: DiscordGatewayPayload) {
|
||||
const {
|
||||
channel_id: channelID,
|
||||
guild_id: guildID,
|
||||
...rest
|
||||
} = payload.d as InviteDeleteEvent;
|
||||
} = payload.d as DiscordInviteDelete;
|
||||
|
||||
eventHandlers.inviteDelete?.({
|
||||
...rest,
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway.ts";
|
||||
import {
|
||||
DiscordGatewayPayload,
|
||||
DiscordPresenceUpdate,
|
||||
} from "../../types/gateway.ts";
|
||||
|
||||
export async function handlePresenceUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as PresenceUpdatePayload;
|
||||
const payload = data.d as DiscordPresenceUpdate;
|
||||
const oldPresence = await cacheHandlers.get("presences", payload.user.id);
|
||||
await cacheHandlers.set("presences", payload.user.id, payload);
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import {
|
||||
DiscordGatewayPayload,
|
||||
DiscordTypingStart,
|
||||
} from "../../types/gateway.ts";
|
||||
|
||||
export function handleTypingStart(data: DiscordPayload) {
|
||||
eventHandlers.typingStart?.(data.d as TypingStartPayload);
|
||||
export function handleTypingStart(data: DiscordGatewayPayload) {
|
||||
eventHandlers.typingStart?.(data.d as DiscordTypingStart);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway.ts";
|
||||
|
||||
export async function handleUserUpdate(data: DiscordPayload) {
|
||||
const userData = data.d as UserPayload;
|
||||
export async function handleUserUpdate(data: DiscordGatewayPayload) {
|
||||
const userData = data.d as DiscordUser;
|
||||
|
||||
const member = await cacheHandlers.get("members", userData.id);
|
||||
if (!member) return;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { DiscordVoiceServerUpdate } from "../../types/gateway.ts";
|
||||
|
||||
export async function handleVoiceServerUpdate(data: DiscordPayload) {
|
||||
const payload = data.d as DiscordVoiceServerUpdateEvent;
|
||||
const payload = data.d as DiscordVoiceServerUpdate;
|
||||
|
||||
const guild = await cacheHandlers.get("guilds", payload.guild_id);
|
||||
if (!guild) return;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway.ts";
|
||||
|
||||
export async function handleVoiceStateUpdate(data: DiscordPayload) {
|
||||
const payload = data.d as VoiceStateUpdatePayload;
|
||||
export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as DiscordVoiceState;
|
||||
if (!payload.guild_id) return;
|
||||
|
||||
const guild = await cacheHandlers.get("guilds", payload.guild_id);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import {
|
||||
DiscordGatewayPayload,
|
||||
DiscordWebhooksUpdate,
|
||||
} from "../../types/gateway.ts";
|
||||
|
||||
export function handleWebhooksUpdate(data: DiscordPayload) {
|
||||
const options = data.d as WebhookUpdatePayload;
|
||||
export function handleWebhooksUpdate(data: DiscordGatewayPayload) {
|
||||
const options = data.d as DiscordWebhooksUpdate;
|
||||
eventHandlers.webhooksUpdate?.(
|
||||
options.channel_id,
|
||||
options.guild_id,
|
||||
|
||||
Reference in New Issue
Block a user