mirror of
https://github.com/sern-handler/sern-community
synced 2026-06-06 01:16:57 +00:00
adding docs.json
This commit is contained in:
20
package-lock.json
generated
20
package-lock.json
generated
@@ -9,8 +9,8 @@
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@sern/handler": "^1.1.3-beta",
|
||||
"discord.js": "^14.0.2",
|
||||
"@sern/handler": "^1.1.7-beta",
|
||||
"discord.js": "^14.0.3",
|
||||
"dotenv": "^16.0.1",
|
||||
"trie-search": "^1.3.6"
|
||||
},
|
||||
@@ -91,11 +91,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@sern/handler": {
|
||||
"version": "1.1.3-beta",
|
||||
"resolved": "https://registry.npmjs.org/@sern/handler/-/handler-1.1.3-beta.tgz",
|
||||
"integrity": "sha512-N7lyW4imVZOuJ9Ap3uxc/qzLBtc47YRJg/FNoiAqfNVijLJDH2J55I13TP4lKY7Y4jhNyBGnYAmH7BrK6TcWSg==",
|
||||
"version": "1.1.7-beta",
|
||||
"resolved": "https://registry.npmjs.org/@sern/handler/-/handler-1.1.7-beta.tgz",
|
||||
"integrity": "sha512-PbwZ61XYTmWJvzYL/AMP+es++KUhyx+qGMzJqwGbuyZcgWnJJV0M6w2bnUFBR5QfKNuGf+88g/ahgjDgSvs7ow==",
|
||||
"dependencies": {
|
||||
"discord.js": "^14.0.1",
|
||||
"discord.js": "^14.0.3",
|
||||
"rxjs": "^7.5.6",
|
||||
"ts-pattern": "^4.0.2",
|
||||
"ts-results": "^3.3.0"
|
||||
@@ -458,11 +458,11 @@
|
||||
"integrity": "sha512-ula2O0kpSZtX9rKXNeQMrHwNd7E4jPDJYUXmEGTFdMRfyfMw+FPyh04oKMjAiDuOi64bYgVkOV3MjK+loImFhQ=="
|
||||
},
|
||||
"@sern/handler": {
|
||||
"version": "1.1.3-beta",
|
||||
"resolved": "https://registry.npmjs.org/@sern/handler/-/handler-1.1.3-beta.tgz",
|
||||
"integrity": "sha512-N7lyW4imVZOuJ9Ap3uxc/qzLBtc47YRJg/FNoiAqfNVijLJDH2J55I13TP4lKY7Y4jhNyBGnYAmH7BrK6TcWSg==",
|
||||
"version": "1.1.7-beta",
|
||||
"resolved": "https://registry.npmjs.org/@sern/handler/-/handler-1.1.7-beta.tgz",
|
||||
"integrity": "sha512-PbwZ61XYTmWJvzYL/AMP+es++KUhyx+qGMzJqwGbuyZcgWnJJV0M6w2bnUFBR5QfKNuGf+88g/ahgjDgSvs7ow==",
|
||||
"requires": {
|
||||
"discord.js": "^14.0.1",
|
||||
"discord.js": "^14.0.3",
|
||||
"rxjs": "^7.5.6",
|
||||
"ts-pattern": "^4.0.2",
|
||||
"ts-results": "^3.3.0"
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start" : "tsc && node ."
|
||||
},
|
||||
"keywords": [
|
||||
"typescript",
|
||||
@@ -13,8 +14,8 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@sern/handler": "^1.1.3-beta",
|
||||
"discord.js": "^14.0.2",
|
||||
"@sern/handler": "^1.1.7-beta",
|
||||
"discord.js": "^14.0.3",
|
||||
"dotenv": "^16.0.1",
|
||||
"trie-search": "^1.3.6"
|
||||
},
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
|
||||
import TrieSearch from 'trie-search';
|
||||
// https://github.com/joshjung/trie-search/issues/30
|
||||
import { commandModule, CommandType } from '@sern/handler';
|
||||
import { ApplicationCommandOptionType } from 'discord.js';
|
||||
import { publish } from '../plugins/publish';
|
||||
import DocHandler from '../trie/doc-autocmp';
|
||||
|
||||
|
||||
|
||||
|
||||
new DocHandler().setup()
|
||||
export default commandModule({
|
||||
type: CommandType.Slash,
|
||||
description : 'Query documentation',
|
||||
|
||||
43
src/trie/doc-autocmp.ts
Normal file
43
src/trie/doc-autocmp.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import TrieSearch from "trie-search";
|
||||
|
||||
|
||||
|
||||
export default class DocHandler {
|
||||
private __DocTrie : TrieSearch<unknown, unknown> | null = null;
|
||||
private mockDoc: Record<string, Record<string,string> | string> = {
|
||||
node: 'gondo',
|
||||
gargantuan : {
|
||||
serendipity : 'discord',
|
||||
shalnark : 'hxh',
|
||||
machi : 'hxh',
|
||||
lucifer: 'devil dude',
|
||||
},
|
||||
experimental : 'goongaginga'
|
||||
};
|
||||
private get pairs() {
|
||||
const keys = Object.keys(this.mockDoc);
|
||||
const output = [] as { key : string, value : string | Record<string,string> }[];
|
||||
while(keys.length !== 0) {
|
||||
const cur = keys.pop()!;
|
||||
const val = this.mockDoc[cur];
|
||||
output.push({ key : cur, value : val });
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
get DocTrie() {
|
||||
return this.__DocTrie;
|
||||
}
|
||||
|
||||
|
||||
|
||||
setup() {
|
||||
|
||||
this.__DocTrie = new TrieSearch([
|
||||
'value'
|
||||
]);
|
||||
this.__DocTrie.addAll(this.pairs);
|
||||
console.log(this.__DocTrie.search('g'))
|
||||
}
|
||||
|
||||
}
|
||||
2
typings/TrieSearch.d.ts
vendored
2
typings/TrieSearch.d.ts
vendored
@@ -71,7 +71,7 @@ declare module 'trie-search' {
|
||||
limit?: number
|
||||
): A | undefined
|
||||
|
||||
search(phrases: string | string[], reducer: null | undefined): T[]
|
||||
search(phrases: string | string[], reducer?: null | undefined): T[]
|
||||
|
||||
search<A>(
|
||||
phrases: string | string[],
|
||||
|
||||
Reference in New Issue
Block a user