mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-10 01:08:07 +01:00
feat: load tags into cache
This commit is contained in:
parent
16fa2fc3e3
commit
97638dc032
16 changed files with 53 additions and 22 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -1,10 +1,9 @@
|
|||
---
|
||||
question: Found a bug in bun?
|
||||
keywords:
|
||||
- bug
|
||||
- report
|
||||
- bugs
|
||||
- "bug"
|
||||
- "report"
|
||||
- "bugs"
|
||||
---
|
||||
|
||||
Found a bug in bun?
|
||||
- If you are unsure, first discuss your bug in <#887787428973281300> or <#995247410794217553>
|
||||
- [Open an issue on GitHub](<https://github.com/oven-sh/bun/issues/new?template=1-bug-report.yml>) and fill out the given template
|
|
@ -1,5 +1,8 @@
|
|||
---
|
||||
keywords: [ bun, bun.sh ]
|
||||
question: What is bun?
|
||||
keywords:
|
||||
- "bun"
|
||||
- "bun.sh"
|
||||
---
|
||||
|
||||
Bun is an all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager.
|
|
@ -1,10 +1,9 @@
|
|||
---
|
||||
question: Any idea what to add to bun?
|
||||
keywords:
|
||||
- feature-request
|
||||
- feature
|
||||
- request
|
||||
- "feature-request"
|
||||
- "feature"
|
||||
- "request"
|
||||
---
|
||||
|
||||
Any idea what to add to bun?
|
||||
- Please consider if this is a request for bun, not for other 3rd party packages
|
||||
- [Open an issue on GitHub](<https://github.com/oven-sh/bun/issues/new?template=2-feature-request.yml>) and fill out the given template
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
question: "How to solve illegal instruction (core dumped) error?"
|
||||
keywords:
|
||||
- "illegal-instruction"
|
||||
- "core-dumped"
|
||||
|
@ -6,9 +7,6 @@ keywords:
|
|||
- "core"
|
||||
- "illegal"
|
||||
---
|
||||
|
||||
**Illegal instruction - core dumped**
|
||||
|
||||
Update to latest version using:
|
||||
```sh
|
||||
curl https://bun.sh/install | bash
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
question: How to upgrade linux kernel?
|
||||
keywords:
|
||||
- "io-uring-is-not-supported"
|
||||
- "io uring"
|
||||
|
@ -6,9 +7,6 @@ keywords:
|
|||
- "update"
|
||||
- "linux"
|
||||
---
|
||||
|
||||
**error: Linux kernel version doesn't support io_uring, which Bun depends on**
|
||||
|
||||
To fix this error, you need to update Linux kernel.
|
||||
If you are using the Windows Subsystem for Linux, do:
|
||||
**1.** Open powershell as administrator
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
question: "How to use bun on NixOS?"
|
||||
keywords:
|
||||
- "nix"
|
||||
- "nixos"
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
question: "Where can i add new tag to bot?"
|
||||
keywords:
|
||||
- tags
|
||||
- contributing
|
||||
- "tags"
|
||||
- "contributing"
|
||||
---
|
||||
|
||||
To create or update tag, check [xHyroM/bun-discord-bot#contributing-tags](<https://github.com/xHyroM/bun-discord-bot/#contributing-tags>)
|
|
@ -1,4 +1,5 @@
|
|||
---
|
||||
question: "Do i need compiler for typescript?"
|
||||
keywords:
|
||||
- "ts"
|
||||
- "typescript"
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
question: "Where can i found windows version of bun?"
|
||||
keywords:
|
||||
- "windows"
|
||||
- "windows support"
|
||||
---
|
||||
|
||||
Bun does not currently have support for Windows, so you must use WSL (Windows Subsystem for Linux).
|
||||
To install WSL, check [microsoft documentation](<https://docs.microsoft.com/en-us/windows/wsl/install>)
|
|
@ -11,6 +11,8 @@
|
|||
"dependencies": {
|
||||
"@paperdave/logger": "^3.0.1",
|
||||
"discord.js": "^14.13.0",
|
||||
"glob": "^10.3.3",
|
||||
"gray-matter": "^4.0.3",
|
||||
"zlib-sync": "^0.1.8"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import "./commands"
|
||||
import "./loaders/tags.ts";
|
||||
import "./commands";
|
||||
import "./listeners";
|
||||
|
||||
import { Bubu } from "./structs/Client.ts";
|
||||
|
|
22
src/loaders/tags.ts
Normal file
22
src/loaders/tags.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import matter from "gray-matter";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { globSync as glob } from "glob";
|
||||
import { join } from "node:path";
|
||||
import { Tag } from "../structs/Tag";
|
||||
|
||||
const tags = glob(join(__dirname, "..", "..", "data", "tags", "*.md"));
|
||||
|
||||
export const TAGS: Tag[] = [];
|
||||
|
||||
for (const tag of tags) {
|
||||
const content = readFileSync(tag);
|
||||
const frontMatter = matter(content);
|
||||
|
||||
TAGS.push({
|
||||
question: frontMatter.data.question,
|
||||
keywords: frontMatter.data.keywords,
|
||||
answer: frontMatter.content
|
||||
});
|
||||
}
|
||||
|
||||
console.log(TAGS);
|
6
src/structs/Tag.ts
Normal file
6
src/structs/Tag.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export interface Tag {
|
||||
question: string;
|
||||
answer: string;
|
||||
keywords: string[];
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
"target": "esnext",
|
||||
"moduleResolution": "Node",
|
||||
"allowImportingTsExtensions": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
// "bun-types" is the important part
|
||||
"types": ["bun-types"]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue