diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts index 918c794..135fb6d 100644 --- a/src/handler/structures/context.ts +++ b/src/handler/structures/context.ts @@ -14,6 +14,7 @@ import type { import { None, Option, Some } from 'ts-results'; import type { Nullish } from '../../types/handler'; import { ExternallyUsed } from '../utilities/externallyUsed'; +import { SernError } from './errors'; function firstSome(...args: Option[]): Nullish { for (const op of args) { @@ -43,7 +44,7 @@ export default class Context { */ @ExternallyUsed public get message() { - return this.oMsg.unwrap(); + return this.oMsg.expect(SernError.MismatchEvent); } /** * Getting the ChatInputCommandInteraction object. Crashes if module type is @@ -52,7 +53,7 @@ export default class Context { */ @ExternallyUsed public get interaction() { - return this.oInterac.unwrap(); + return this.oInterac.expect(SernError.MismatchEvent); } @ExternallyUsed diff --git a/src/handler/structures/errors.ts b/src/handler/structures/errors.ts index f95f2cf..87a7232 100644 --- a/src/handler/structures/errors.ts +++ b/src/handler/structures/errors.ts @@ -4,4 +4,5 @@ export enum SernError { MismatchModule = `A module type mismatched with event emitted!`, NotSupportedInteraction = `This interaction is not supported.`, PluginFailure = `A plugin failed to call controller.next()`, + MismatchEvent = `You cannot use message when an interaction fired or vice versa`, }