Files
discordeno/src/api/controllers/interactions.ts
Ayyan e5a8f3b358 chore: setup "deno lint" (#331)
* chore: setup "deno lint"

* ci(lint): add --unstable flat to lint script

* lint

* lint

* refactor: destructure assignment for Message#guildID

* chore: remove TODO comment

* refactor: remove redundant async

* chore: switch to Deno stable vscode ext

* chore: remove ignore comments

* chore: remove ignore comments

* chore: remove @ts-ignore comment

* fixes

* fixes

* chore: remove deno-lint-ignore comment

* chore: add index signature
2021-01-03 20:12:42 +04:00

28 lines
743 B
TypeScript

import { eventHandlers } from "../../bot.ts";
import {
Application,
DiscordPayload,
InteractionCommandPayload,
} from "../../types/mod.ts";
import { structures } from "../structures/mod.ts";
export async function handleInternalInteractionCreate(data: DiscordPayload) {
if (data.t !== "INTERACTION_CREATE") return;
const payload = data.d as InteractionCommandPayload;
eventHandlers.interactionCreate?.(
{
...payload,
member: await structures.createMember(payload.member, payload.guild_id),
},
);
}
export function handleInternalApplicationCommandCreate(
data: DiscordPayload,
) {
if (data.t !== "APPLICATION_COMMAND_CREATE") return;
eventHandlers.applicationCommandCreate?.(data.d as Application);
}