-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
504 additions
and
687 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# @kotori-bot/core | ||
|
||
## Reference | ||
|
||
- [Kotori Docs](https://kotori.js.org/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,37 @@ | ||
interface DevErrorExtra { | ||
path: string; | ||
type: 'warning' | 'info' | 'error'; | ||
} | ||
|
||
type KotoriErrorType = 'DatabaseError' | 'ModuleError' | 'UnknownError' | 'DevError'; | ||
type KotoriErrorLevel = 'debug' | 'normal' | 'log'; | ||
|
||
interface KotoriErrorImpl { | ||
readonly name: KotoriErrorType; | ||
readonly level: KotoriErrorLevel; | ||
readonly extend: () => typeof KotoriError; | ||
} | ||
|
||
export class KotoriError<T extends object = object> extends Error implements KotoriErrorImpl { | ||
constructor(message?: string, extra?: T, type: KotoriErrorType = 'UnknownError', level: KotoriErrorLevel = 'debug') { | ||
constructor(message?: string, extra?: T, type: KotoriErrorType = 'UnknownError') { | ||
super(message); | ||
this.name = type; | ||
this.level = level; | ||
this.extra = extra; | ||
} | ||
|
||
readonly extra?: T; | ||
|
||
readonly name: KotoriErrorType; | ||
|
||
readonly level: KotoriErrorLevel; | ||
|
||
extend(): typeof KotoriError<T> { | ||
const { message: fatherMessage, name: fatherType, level: fatherLevel, extra: fatherExtra } = this; | ||
const { message: fatherMessage, name: fatherType, extra: fatherExtra } = this; | ||
// const newClass: typeof KotoriError = Object.create(KotoriError); | ||
return new Proxy(KotoriError<T>, { | ||
construct(Class, params) { | ||
const args = params; | ||
args[0] = `${fatherMessage} ${args[0]}`; | ||
args[1] = args[1] ?? fatherExtra; | ||
args[2] = args[2] ?? fatherType; | ||
args[3] = args[3] ?? fatherLevel; | ||
return new Class(...args); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export const ModuleError = new KotoriError(undefined, undefined, 'ModuleError', 'normal').extend(); | ||
export const DevError = new KotoriError<DevErrorExtra>(undefined, undefined, 'DevError', 'debug').extend(); | ||
export const ModuleError = new KotoriError(undefined, undefined, 'ModuleError').extend(); | ||
export const DevError = new KotoriError(undefined, undefined, 'DevError').extend(); | ||
|
||
export default KotoriError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
import { Loader } from '@kotori-bot/loader'; | ||
import { obj } from '@kotori-bot/core'; | ||
|
||
(globalThis as obj).env_mode = 'dev'; | ||
|
||
const kotori = new Loader(); | ||
const kotori = new Loader({ mode: 'dev' }); | ||
kotori.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
import { Loader } from '@kotori-bot/loader'; | ||
import { obj } from '@kotori-bot/core'; | ||
|
||
(globalThis as obj).env_mode = 'build'; | ||
|
||
const kotori = new Loader(); | ||
const kotori = new Loader({ mode: 'build' }); | ||
kotori.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.