From a52ad270d843e92db5bf2049d07527eed59d428c Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:37:51 -0600 Subject: [PATCH 1/3] fix: context-interactions error (#382) --- src/core/functions.ts | 3 +++ src/handlers/interaction.ts | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core/functions.ts b/src/core/functions.ts index da11191..00c4a7e 100644 --- a/src/core/functions.ts +++ b/src/core/functions.ts @@ -119,6 +119,9 @@ export function isMessageComponent(i: InteractionTypable): i is AnyMessageCompon export function isCommand(i: InteractionTypable): i is AnyCommandInteraction { return i.type === InteractionType.ApplicationCommand; } +export function isContextCommand(i: AnyCommandInteraction): i is MessageContextMenuCommandInteraction | UserContextMenuCommandInteraction { + return i.isContextMenuCommand(); +} export function isAutocomplete(i: InteractionTypable): i is AutocompleteInteraction { return i.type === InteractionType.ApplicationCommandAutocomplete; } diff --git a/src/handlers/interaction.ts b/src/handlers/interaction.ts index 2fba5ce..814db70 100644 --- a/src/handlers/interaction.ts +++ b/src/handlers/interaction.ts @@ -1,7 +1,7 @@ import type { Module } from '../types/core-modules' import { callPlugins, executeModule } from './event-utils'; import { SernError } from '../core/structures/enums' -import { createSDT, isAutocomplete, isCommand, isMessageComponent, isModal, resultPayload, treeSearch } from '../core/functions' +import { createSDT, isAutocomplete, isCommand, isContextCommand, isMessageComponent, isModal, resultPayload, treeSearch } from '../core/functions' import type { UnpackedDependencies } from '../types/utility'; import * as Id from '../core/id' import { Context } from '../core/structures/context'; @@ -29,13 +29,23 @@ export function interactionHandler(deps: UnpackedDependencies, defaultPrefix?: s } const { module, params } = modules.at(0)!; let payload; + // handles autocomplete if(isAutocomplete(event)) { //@ts-ignore stfu const { command } = treeSearch(event, module.options); payload= { module: command as Module, //autocomplete is not a true "module" warning cast! args: [event, createSDT(command, deps, params)] }; + // either CommandTypes Slash | ContextMessage | ContextUesr } else if(isCommand(event)) { - payload= { module, args: [Context.wrap(event, defaultPrefix), createSDT(module, deps, params)] }; + const sdt = createSDT(module, deps, params) + // handle CommandType.CtxUser || CommandType.CtxMsg + if(isContextCommand(event)) { + payload= { module, args: [event, sdt] }; + } else { + // handle CommandType.Slash || CommandType.Both + payload= { module, args: [Context.wrap(event, defaultPrefix), sdt] }; + } + // handles modals or components } else if (isModal(event) || isMessageComponent(event)) { payload= { module, args: [event, createSDT(module, deps, params)] } } else { From 97fa2a2d78c3a1c6ed45dcf1c5e018fdde11726b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 16:38:33 -0600 Subject: [PATCH 2/3] chore(main): release 4.2.1 (#383) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0185bc5..8f5e67a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [4.2.1](https://github.com/sern-handler/handler/compare/v4.2.0...v4.2.1) (2025-01-24) + + +### Bug Fixes + +* context-interactions error ([#382](https://github.com/sern-handler/handler/issues/382)) ([a52ad27](https://github.com/sern-handler/handler/commit/a52ad270d843e92db5bf2049d07527eed59d428c)) + ## [4.2.0](https://github.com/sern-handler/handler/compare/v4.1.1...v4.2.0) (2025-01-18) diff --git a/package.json b/package.json index 490b1ca..517739c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@sern/handler", "packageManager": "yarn@3.5.0", - "version": "4.2.0", + "version": "4.2.1", "description": "A complete, customizable, typesafe, & reactive framework for discord bots.", "main": "./dist/index.js", "module": "./dist/index.js", From 1b7f2a49a877de43f068abebcc987669ca1b0aad Mon Sep 17 00:00:00 2001 From: Ararou Date: Sat, 25 Jan 2025 22:26:31 -0600 Subject: [PATCH 3/3] change formatting of example projects (#384) --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d26813e..ca4a4e4 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ - Lightweight. Does a lot while being small. - Latest features. Support for discord.js v14 and all of its interactions. - Start quickly. Plug and play or customize to your liking. -- works with [bun](https://bun.sh/) and [node](https://nodejs.org/en) out the box! +- Works with [bun](https://bun.sh/) and [node](https://nodejs.org/en) out the box! - Use it with TypeScript or JavaScript. CommonJS and ESM supported. - Active and growing community, always here to help. [Join us](https://sern.dev/discord) - Unleash its full potential with a powerful CLI and awesome plugins. @@ -45,14 +45,14 @@ export default commandModule({ ## 🤖 Bots Using sern -- [Community Bot](https://github.com/sern-handler/sern-community), the community bot for our [discord server](https://sern.dev/discord). -- [Vinci](https://github.com/SrIzan10/vinci), the bot for Mara Turing. -- [Bask](https://github.com/baskbotml/bask), Listen your favorite artists on Discord. -- [Murayama](https://github.com/murayamabot/murayama), :pepega: -- [Protector](https://github.com/GlitchApotamus/Protector), Just a simple bot to help enhance a private minecraft server. -- [SmokinWeed 💨](https://github.com/Peter-MJ-Parker/sern-bud), A fun bot for a small - but growing - server. -- [Man Nomic](https://github.com/jacoobes/man-nomic), A simple information bot to provide information to the nomic-ai discord community. -- [Linear-Discord](https://github.com/sern-handler/linear-discord) Display and manage a linear dashboard. +- [Community Bot](https://github.com/sern-handler/sern-community) - The community bot for our [Discord server](https://sern.dev/discord). +- [Vinci](https://github.com/SrIzan10/vinci) - The bot for Mara Turing. +- [Bask](https://github.com/baskbotml/bask) - Listen to your favorite artists on Discord. +- [Murayama](https://github.com/murayamabot/murayama) - :pepega: +- [Protector](https://github.com/GlitchApotamus/Protector) - Just a simple bot to help enhance a private Minecraft server. +- [SmokinWeed 💨](https://github.com/Peter-MJ-Parker/sern-bud) - A fun bot for a small, but growing server. +- [Man Nomic](https://github.com/jacoobes/man-nomic) - A simple information bot to provide information to the nomic-ai Discord community. +- [Linear-Discord](https://github.com/sern-handler/linear-discord) - Display and manage a linear dashboard. ## 💻 CLI It is **highly encouraged** to use the [command line interface](https://github.com/sern-handler/cli) for your project. Don't forget to view it.