mirror of
https://github.com/jaronpate/unicord.git
synced 2026-10-18 21:47:40 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1aa0fbb9e2 | |||
| be82580f90 | |||
| 63755fe17a |
@@ -1,4 +1,4 @@
|
|||||||
name: CI
|
name: CI (template)
|
||||||
on: workflow_dispatch
|
on: workflow_dispatch
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -4,14 +4,15 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
# Pull repo
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/checkout@v2
|
||||||
with:
|
# Install bun
|
||||||
node-version: 14
|
- uses: oven-sh/setup-bun@v2
|
||||||
registry-url: https://registry.npmjs.org/
|
# Run tests
|
||||||
- run: yarn
|
# TODO: Add tests
|
||||||
- run: yarn build
|
# Build
|
||||||
# - run: yarn test
|
- run: bun build
|
||||||
- run: yarn publish --access public
|
# Publish
|
||||||
|
- run: bun publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
NPM_CONFIG_REGISTRY: https://registry.npmjs.org/_authToken=${{ secrets.NPM_TOKEN }}
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "unicord",
|
"name": "unicord",
|
||||||
"description": "A simple discord library primarily for TypeScript. REST like and easy to use.",
|
"description": "A simple discord library primarily for TypeScript. Web server like and easy to use.",
|
||||||
"version": "0.0.2",
|
"version": "0.0.4",
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "out/index.js",
|
"main": "out/index.js",
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"build:packages": "bun run build:types && bun run build:core -- --packages external",
|
"build:packages": "bun run build:types && bun run build:core -- --packages external",
|
||||||
"build:nocheck": "bun run build:types:nocheck && bun run build:core",
|
"build:nocheck": "bun run build:types:nocheck && bun run build:core",
|
||||||
|
|
||||||
"build:core": "bun build src/index.ts --outdir out --drop=console --drop=debugger",
|
"build:core": "bun build src/index.ts --outdir out --drop=debugger",
|
||||||
"build:types": "tsc --emitDeclarationOnly --project tsconfig.json",
|
"build:types": "tsc --emitDeclarationOnly --project tsconfig.json",
|
||||||
"build:types:nocheck": "bun run build:types -- --noCheck",
|
"build:types:nocheck": "bun run build:types -- --noCheck",
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const EventBus = new EventEmitter() as Emitter;
|
|||||||
|
|
||||||
export type Emitter = EventEmitter & {
|
export type Emitter = EventEmitter & {
|
||||||
emit: (event_name: string, context: Context | null, ...args: any[]) => boolean
|
emit: (event_name: string, context: Context | null, ...args: any[]) => boolean
|
||||||
|
on: (event_name: string, listener: Function) => Emitter
|
||||||
}
|
}
|
||||||
|
|
||||||
export { EventBus };
|
export { EventBus };
|
||||||
@@ -205,15 +205,15 @@ export class Gateway {
|
|||||||
// Generate context
|
// Generate context
|
||||||
const context = new Context(this.client, this.api, { message });
|
const context = new Context(this.client, this.api, { message });
|
||||||
// Dispatch event for the command
|
// Dispatch event for the command
|
||||||
this.bus.emit(`command:${command}`, context, args);
|
// this.bus.emit(`${HandlerType.ChatCommands}:${command}`, context, args);
|
||||||
// // Check if command exists
|
// // Check if command exists
|
||||||
// if (this.processor[HandlerType.ChatCommands].has(command)) {
|
if (this.processor[HandlerType.ChatCommands].has(command)) {
|
||||||
// // Execute the handler
|
// Execute the handler
|
||||||
// this.processor[HandlerType.ChatCommands].execute(command, context, args);
|
this.processor[HandlerType.ChatCommands].execute(command, context, args);
|
||||||
// } else {
|
} else {
|
||||||
// // TODO: Custom unknown command handler
|
// TODO: Custom unknown command handler
|
||||||
// context.reply(`Unknown command: ${command}`);
|
// context.reply(`Unknown command: ${command}`);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ export class Processor {
|
|||||||
throw new Error('Event handlers cannot be a CommandHandler');
|
throw new Error('Event handlers cannot be a CommandHandler');
|
||||||
}
|
}
|
||||||
// Validate and resolve the args
|
// Validate and resolve the args
|
||||||
|
// TODO: There's no reason this can't use the hydrator system
|
||||||
|
// Hydrator should have a more genric subcomponent that can be used anywhere and is more dumb.
|
||||||
|
// Basically a function that accepts id's and returns values.
|
||||||
const resolvedArgs = await this.validateAndResolveArgs(argsOrPayload, handler.args);
|
const resolvedArgs = await this.validateAndResolveArgs(argsOrPayload, handler.args);
|
||||||
// Execute the handler
|
// Execute the handler
|
||||||
await Promise.resolve(handler[Trait.execute](context!, resolvedArgs));
|
await Promise.resolve(handler[Trait.execute](context!, resolvedArgs));
|
||||||
|
|||||||
Reference in New Issue
Block a user