harmony/src/gateway/handlers/applicationCommandCreate.ts

16 lines
576 B
TypeScript
Raw Normal View History

2021-04-04 05:42:15 +00:00
import { SlashCommand } from '../../interactions/slashCommand.ts'
2021-01-26 20:15:47 +00:00
import { ApplicationCommandPayload } from '../../types/gateway.ts'
2021-04-04 05:42:15 +00:00
import type { Gateway, GatewayEventHandler } from '../mod.ts'
2021-01-26 20:15:47 +00:00
export const applicationCommandCreate: GatewayEventHandler = async (
gateway: Gateway,
d: ApplicationCommandPayload
) => {
const guild =
d.guild_id === undefined
? undefined
: await gateway.client.guilds.get(d.guild_id)
const cmd = new SlashCommand(gateway.client.slash.commands, d, guild)
gateway.client.emit('slashCommandCreate', cmd)
}