mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
chore: resolved conflicts
This commit is contained in:
71
README.md
71
README.md
@@ -1,6 +1,8 @@
|
||||
# Sern
|
||||
# Sern Handler
|
||||
<a href="https://www.npmjs.com/package/sern_handler">
|
||||
<img src="https://img.shields.io/npm/v/sern_handler?maxAge=3600" alt="NPM version" /></a> <a href="https://www.npmjs.com/package/shandler"><img src="https://img.shields.io/npm/dt/sern_handler?maxAge=3600" alt="NPM downloads" /></a> <a href="https://www.npmjs.com/package/sern_handler"><img src="https://img.shields.io/badge/builds-stable" alt="Builds Passing"></a>
|
||||
|
||||
Sern is making easier to create & automate your discord bot with new version compatibility and full customization.
|
||||
Sern automates and streamlines development your discord bot with new version compatibility and full customization.
|
||||
|
||||
- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler)
|
||||
|
||||
@@ -9,44 +11,79 @@ Sern is making easier to create & automate your discord bot with new version com
|
||||
```sh
|
||||
npm install sern-handler
|
||||
```
|
||||
|
||||
```sh
|
||||
yarn add sern-handler
|
||||
```
|
||||
```sh
|
||||
pnpm add sern-handler
|
||||
```
|
||||
|
||||
# Basic Usage
|
||||
|
||||
### [Typescript](https://www.typescriptlang.org/)
|
||||
|
||||
##### [Typescript](https://www.typescriptlang.org/)
|
||||
```ts
|
||||
import { Client } from 'discord.js';
|
||||
import { Intents } from 'discord.js';
|
||||
import { prefix, token } from '../src/secrets.json';
|
||||
import { Client, Intents } from 'discord.js'
|
||||
import { Sern } from 'sern-handler';
|
||||
import { prefix, token } from '../src/secrets.json';
|
||||
|
||||
const client = new Client({
|
||||
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS],
|
||||
intents: [
|
||||
Intents.FLAGS.GUILDS,
|
||||
Intents.FLAGS.GUILD_MESSAGES,
|
||||
Intents.FLAGS.GUILD_MEMBERS
|
||||
]
|
||||
});
|
||||
|
||||
new Sern.Handler({
|
||||
client,
|
||||
prefix,
|
||||
commands: 'dist/commands', // after compiling with tsc
|
||||
privateServers: [
|
||||
commands : 'dist/commands', // If using typescript, target your outDir/~
|
||||
privateServers : [
|
||||
{
|
||||
test: true,
|
||||
id: 'server id',
|
||||
},
|
||||
test : true,
|
||||
id: 'server-id'
|
||||
}
|
||||
],
|
||||
init: async (handler: Sern.Handler) => {
|
||||
/* an optional function to initialize anything else on bot startup */
|
||||
init: async (handler : Sern.Handler) => {
|
||||
// Optional function to initialize anything else on bot startup
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
##### [JavaScript](https://www.javascript.com)
|
||||
```js
|
||||
import { Client, Intents } from 'discord.js';
|
||||
import { Sern } from 'sern-handler';
|
||||
import { prefix, token } from '../src/secrets.json';
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
Intents.FLAGS.GUILDS,
|
||||
Intents.FLAGS.GUILD_MESSAGES,
|
||||
Intents.FLAGS.GUILD_MEMBERS
|
||||
]
|
||||
});
|
||||
|
||||
new Sern.Handler({
|
||||
client,
|
||||
prefix,
|
||||
commands : 'dist/commands',
|
||||
privateServers : [
|
||||
{
|
||||
test : true,
|
||||
id: 'server-id'
|
||||
}
|
||||
],
|
||||
init: async (handler) => {
|
||||
// Optional function to initialize anything else on bot startup
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
client.login(token);
|
||||
```
|
||||
|
||||
## Links 
|
||||
## Links 
|
||||
|
||||
- 📑 Official Documentation
|
||||
- 🎧 Discord Server
|
||||
|
||||
1205
package-lock.json
generated
1205
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,8 @@
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"format": "eslint src/**/*.ts --fix",
|
||||
"release": "standard-version && git push --follow-tags",
|
||||
"test": "jest --coverage --verbose"
|
||||
"test": "jest --coverage --verbose",
|
||||
"commit": "cz"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
@@ -29,14 +30,14 @@
|
||||
"@babel/preset-typescript": "^7.16.7",
|
||||
"@types/jest": "^27.4.0",
|
||||
"babel-jest": "^27.5.1",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"cz-conventional-changelog": "^3.0.1",
|
||||
"jest": "^27.5.1",
|
||||
"standard-version": "^9.3.2",
|
||||
"typescript": "^4.5.5"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
"path": "cz-conventional-changelog"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ export class Handler {
|
||||
|
||||
if (parsedArgs.err) return parsedArgs.val;
|
||||
|
||||
return (await module.mod.delegate(context, parsedArgs))?.val;
|
||||
return (await module.mod.execute(context, parsedArgs))?.val;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ export class Handler {
|
||||
};
|
||||
const parsedArgs = module.mod.parse?.(context, ['text', args]) ?? Ok('');
|
||||
if (parsedArgs.err) return parsedArgs.val;
|
||||
return (await module.mod.delegate(context, parsedArgs))?.val;
|
||||
return (await module.mod.execute(context, parsedArgs))?.val;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,7 +274,7 @@ export interface Module<T = string> {
|
||||
visibility: Visibility;
|
||||
type: CommandType;
|
||||
test: boolean;
|
||||
delegate: (eventParams: Context, args: Ok<T>) => Awaitable<Result<possibleOutput, string> | void>;
|
||||
execute: (eventParams: Context, args: Ok<T>) => Awaitable<Result<possibleOutput, string> | void>;
|
||||
parse?: (ctx: Context, args: Arg) => Utils.ArgType<T>;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ export type Visibility = 'private' | 'public';
|
||||
// Anything that can be sent in a `<TextChannel>#send` or `<CommandInteraction>#reply`
|
||||
export type possibleOutput<T = string> = T | (MessagePayload & MessageOptions);
|
||||
export type Nullable<T> = T | null;
|
||||
export type delegate = Sern.Module<unknown>['delegate'];
|
||||
export type execute = Sern.Module<unknown>['execute'];
|
||||
|
||||
// Thanks @cursorsdottsx
|
||||
export type ParseType<T> = {
|
||||
|
||||
Reference in New Issue
Block a user