mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
feat: more clear error for access message or interaction
This commit is contained in:
@@ -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<T>(...args: Option<T>[]): Nullish<T> {
|
||||
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
|
||||
|
||||
@@ -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`,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user