Skip to content

Commit

Permalink
Migrate to JSONC
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Jul 14, 2024
1 parent dcf0f0e commit 83b33cb
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 108 deletions.
4 changes: 4 additions & 0 deletions .github/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
// This file supports comments and trailing commas
"auth": {
"clientId": "<CLIENT_ID>",
"token": "<BOT_TOKEN>"
Expand All @@ -7,16 +8,19 @@
"dsn": null
},
"activity": {
// https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types
"type": 0,
"name": "Die Jungs von der CSZ sind mir heilig."
},
"prefix": {
// You may want to choose a prefix that does not collide with others on the test server
"command": ".",
"modCommand": "~"
},
"moderatorRoleIds": [
"893179190709477413"
],

"command": {
"faulenzerPing": {
"allowedRoleIds": [],
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@jsr:registry=https://npm.jsr.io
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"files.eol": "\n",
"cSpell.language": "de,en",
"editor.formatOnSaveMode": "modificationsIfAvailable",
"files.associations": {
"config*.json": "jsonc"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ bun i
cp config.template.json config.json
$EDITOR config.json
```
Hinweis: Die Datei kann Kommentare und Trailing-Commas (JSONC). Wenn du nicht VSCode verwendest, musst du das ggf. noch einstellen.
2. Das Template ist für die [Coding-Test-Zentrale](https://discord.gg/ekJA6GA3BJ) vorausgefüllt. Es fehlen noch:
- Um einen Bot zum Testen anzulegen, einfach den Instruktionen im [Discord Developer Portal](https://discord.com/developers/applications) folgen.
- Die Applikation muss als "Bot" gesetzt werden.
Expand Down
Binary file modified bun.lockb
Binary file not shown.
107 changes: 0 additions & 107 deletions config.new.jsonc

This file was deleted.

4 changes: 4 additions & 0 deletions config.template.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
// This file supports comments and trailing commas
"auth": {
"clientId": "<CLIENT_ID>",
"token": "<BOT_TOKEN>"
Expand All @@ -7,16 +8,19 @@
"dsn": null
},
"activity": {
// https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types
"type": 0,
"name": "Hi!"
},
"prefix": {
// You may want to choose a prefix that does not collide with others on the test server
"command": "xd",
"modCommand": "yd"
},
"moderatorRoleIds": [
"893179190709477413"
],

"command": {
"faulenzerPing": {
"allowedRoleIds": [],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@napi-rs/canvas": "^0.1.53",
"@resvg/resvg-js": "^2.6.2",
"@sentry/bun": "^8.17.0",
"@std/jsonc": "npm:@jsr/std__jsonc@^1.0.0-rc.2",
"chrono-node": "^2.7.6",
"croner": "^8.1.0",
"discord.js": "^14.15.3",
Expand Down
4 changes: 3 additions & 1 deletion src/service/configService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as fs from "node:fs/promises";
import * as path from "node:path";
import { parseArgs } from "node:util";

import * as JSONC from "@std/jsonc";

import type { Snowflake, ActivityType } from "discord.js";

import log from "@log";
Expand All @@ -27,7 +29,7 @@ export async function readConfig() {
}

try {
return JSON.parse(jsonString) as Config;
return JSONC.parse(jsonString) as unknown as Config;
} catch (e) {
log.error(e, "Config is not valid JSON. Stopping...");
return process.exit(1);
Expand Down

0 comments on commit 83b33cb

Please sign in to comment.