From 63dabb8466d76ff0e520f464a5523c915e807e4b Mon Sep 17 00:00:00 2001 From: a Date: Sun, 15 Jun 2025 00:10:03 -0500 Subject: [PATCH] noot --- ts/src/discord/botevent/command_parser.spec.ts | 10 +++++----- ts/src/discord/botevent/command_parser.ts | 4 ++-- ts/src/discord/botevent/handler.ts | 9 +++++++-- ts/src/discord/index.ts | 5 ++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ts/src/discord/botevent/command_parser.spec.ts b/ts/src/discord/botevent/command_parser.spec.ts index dbec695..d343cd4 100644 --- a/ts/src/discord/botevent/command_parser.spec.ts +++ b/ts/src/discord/botevent/command_parser.spec.ts @@ -1,6 +1,6 @@ import { ApplicationCommandOptionTypes, ApplicationCommandTypes, type CreateApplicationCommand } from '@discordeno/types' import { describe, expect, it, vi } from 'vitest' -import type { InteractionData } from '..' +import type { InteractionData } from 'discordeno' import { type ExtractCommands, createCommandHandler } from './command_parser' // Test command definitions @@ -132,13 +132,13 @@ function createMockHandlers() { function createTestSetup() { const handlers = createMockHandlers() const notFoundHandler = vi.fn() - + const handler = createCommandHandler({ commands: TEST_COMMANDS, handler: handlers, notFoundHandler, }) - + return { handlers, notFoundHandler, @@ -429,7 +429,7 @@ describe('ExtractCommands type utility', () => { it('should handle different option types', async () => { const { type } = await import('arktype') - + const TYPE_TEST_COMMANDS = [ { name: 'types', @@ -468,7 +468,7 @@ describe('ExtractCommands type utility', () => { types: async (args) => { // Validate the args using arktype const result = argsValidator(args) - + // Check if validation passed (result is the validated object, not wrapped) if (result instanceof type.errors) { expect.fail(`Validation failed: ${result.summary}`) diff --git a/ts/src/discord/botevent/command_parser.ts b/ts/src/discord/botevent/command_parser.ts index f21700d..dd52f12 100644 --- a/ts/src/discord/botevent/command_parser.ts +++ b/ts/src/discord/botevent/command_parser.ts @@ -1,9 +1,9 @@ import { ApplicationCommandOptionTypes } from '@discordeno/types' import type {CreateApplicationCommand, DiscordInteractionDataOption, - DiscordInteractionData, DiscordApplicationCommandOption }from '@discordeno/types' +import type {InteractionData} from 'discordeno' import type { SLASH_COMMANDS } from './slash_commands' // Map option types to their TypeScript types @@ -157,7 +157,7 @@ export function createCommandHandler notFoundHandler: HandlerFunction<{path?: string}> }) { - return async (data: DiscordInteractionData): Promise => { + return async (data: InteractionData): Promise => { if (!data || !data.name) { await notFoundHandler({}) return diff --git a/ts/src/discord/botevent/handler.ts b/ts/src/discord/botevent/handler.ts index 0629652..41920ab 100644 --- a/ts/src/discord/botevent/handler.ts +++ b/ts/src/discord/botevent/handler.ts @@ -1,5 +1,5 @@ import { Client } from '@temporalio/client' -import { ActivityTypes, InteractionTypes } from 'discordeno' +import { ActivityTypes, InteractionData, InteractionTypes } from 'discordeno' import { c } from '#/di' import type { BotType } from '#/discord' import { Bot } from '#/discord/bot' @@ -14,9 +14,14 @@ export const events = () => { if (interaction.type !== InteractionTypes.ApplicationCommand) { return } + if (!interaction.data) { + return + } const temporalClient = await c.getAsync(Client) + let data: Omit = interaction.data + // Start the workflow to handle the interaction const handle = await temporalClient.workflow.start(workflowHandleInteractionCreate, { args: [ @@ -27,7 +32,7 @@ export const events = () => { type: interaction.type, acknowledged: interaction.acknowledged, }, - data: interaction.data, + data, }, ], workflowId: `discord-interaction-${interaction.id}`, diff --git a/ts/src/discord/index.ts b/ts/src/discord/index.ts index 779b5f2..febf9ae 100644 --- a/ts/src/discord/index.ts +++ b/ts/src/discord/index.ts @@ -1,6 +1,5 @@ import { Intents, type InteractionTypes } from '@discordeno/types' -import type { DiscordInteractionData} from '@discordeno/types' -import type { Bot, CompleteDesiredProperties, DesiredPropertiesBehavior } from 'discordeno' +import type { Bot, CompleteDesiredProperties, DesiredPropertiesBehavior, InteractionData } from 'discordeno' export const intents = [ Intents.GuildModeration, Intents.GuildWebhooks, @@ -60,5 +59,5 @@ export interface InteractionRef { // Type for the complete interaction handling payload export interface InteractionCreatePayload { ref: InteractionRef - data: DiscordInteractionData + data: Omit }