mirror of
https://github.com/sern-handler/handler
synced 2026-06-25 09:12:15 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97fa2a2d78 | ||
|
|
a52ad270d8 |
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# 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)
|
## [4.2.0](https://github.com/sern-handler/handler/compare/v4.1.1...v4.2.0) (2025-01-18)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@sern/handler",
|
"name": "@sern/handler",
|
||||||
"packageManager": "yarn@3.5.0",
|
"packageManager": "yarn@3.5.0",
|
||||||
"version": "4.2.0",
|
"version": "4.2.1",
|
||||||
"description": "A complete, customizable, typesafe, & reactive framework for discord bots.",
|
"description": "A complete, customizable, typesafe, & reactive framework for discord bots.",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.js",
|
"module": "./dist/index.js",
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ export function isMessageComponent(i: InteractionTypable): i is AnyMessageCompon
|
|||||||
export function isCommand(i: InteractionTypable): i is AnyCommandInteraction {
|
export function isCommand(i: InteractionTypable): i is AnyCommandInteraction {
|
||||||
return i.type === InteractionType.ApplicationCommand;
|
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 {
|
export function isAutocomplete(i: InteractionTypable): i is AutocompleteInteraction {
|
||||||
return i.type === InteractionType.ApplicationCommandAutocomplete;
|
return i.type === InteractionType.ApplicationCommandAutocomplete;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Module } from '../types/core-modules'
|
import type { Module } from '../types/core-modules'
|
||||||
import { callPlugins, executeModule } from './event-utils';
|
import { callPlugins, executeModule } from './event-utils';
|
||||||
import { SernError } from '../core/structures/enums'
|
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 type { UnpackedDependencies } from '../types/utility';
|
||||||
import * as Id from '../core/id'
|
import * as Id from '../core/id'
|
||||||
import { Context } from '../core/structures/context';
|
import { Context } from '../core/structures/context';
|
||||||
@@ -29,13 +29,23 @@ export function interactionHandler(deps: UnpackedDependencies, defaultPrefix?: s
|
|||||||
}
|
}
|
||||||
const { module, params } = modules.at(0)!;
|
const { module, params } = modules.at(0)!;
|
||||||
let payload;
|
let payload;
|
||||||
|
// handles autocomplete
|
||||||
if(isAutocomplete(event)) {
|
if(isAutocomplete(event)) {
|
||||||
//@ts-ignore stfu
|
//@ts-ignore stfu
|
||||||
const { command } = treeSearch(event, module.options);
|
const { command } = treeSearch(event, module.options);
|
||||||
payload= { module: command as Module, //autocomplete is not a true "module" warning cast!
|
payload= { module: command as Module, //autocomplete is not a true "module" warning cast!
|
||||||
args: [event, createSDT(command, deps, params)] };
|
args: [event, createSDT(command, deps, params)] };
|
||||||
|
// either CommandTypes Slash | ContextMessage | ContextUesr
|
||||||
} else if(isCommand(event)) {
|
} 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)) {
|
} else if (isModal(event) || isMessageComponent(event)) {
|
||||||
payload= { module, args: [event, createSDT(module, deps, params)] }
|
payload= { module, args: [event, createSDT(module, deps, params)] }
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user