@wolfstar/shared-http-pieces 1.2.9 → 1.2.10-next-20260829215854
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -108
- package/dist/index.js.map +1 -1
- package/dist/register.d.ts +10 -1
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +224 -3
- package/dist/register.js.map +1 -1
- package/dist/sentry-Dik0uTiq.js +112 -0
- package/dist/sentry-Dik0uTiq.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ The shared commands used for Star Network's HTTP-only bots.
|
|
|
6
6
|
|
|
7
7
|
- Define `locales/{{lng}}/commands/shared:infoEmbedDescription` as a string. This is the content displayed in `/info`'s embed description.
|
|
8
8
|
- Define the information variables.
|
|
9
|
+
- Importing `@wolfstar/shared-http-pieces/register` registers a `preGenericsInitialization` hook
|
|
10
|
+
that adds this package's bundled locales to your `Client`'s i18n backend automatically — as long
|
|
11
|
+
as it's imported before `new Client(...)`, no manual wiring is required. The resolved path is
|
|
12
|
+
also exported as `localesPath`, if you need it directly.
|
|
9
13
|
|
|
10
14
|
## Usage
|
|
11
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,29 +2,29 @@ import * as Sentry from "@sentry/node";
|
|
|
2
2
|
declare namespace Shared_d_exports {
|
|
3
3
|
export { DonateDescription, DonateName, DonateResponse, InfoButtonDonate, InfoButtonGitHub, InfoButtonInvite, InfoButtonSupport, InfoDescription, InfoEmbedDescription, InfoFieldServerUsageTitle, InfoFieldServerUsageValue, InfoFieldUptimeTitle, InfoFieldUptimeValue, InfoName };
|
|
4
4
|
}
|
|
5
|
-
declare const DonateName: import("@wolfstar/
|
|
6
|
-
declare const DonateDescription: import("@wolfstar/
|
|
7
|
-
declare const DonateResponse: import("@wolfstar/
|
|
5
|
+
declare const DonateName: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
6
|
+
declare const DonateDescription: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
7
|
+
declare const DonateResponse: import("@wolfstar/plugin-i18next").TypedFT<{
|
|
8
8
|
urls: string;
|
|
9
9
|
}, string>;
|
|
10
|
-
declare const InfoName: import("@wolfstar/
|
|
11
|
-
declare const InfoDescription: import("@wolfstar/
|
|
12
|
-
declare const InfoEmbedDescription: import("@wolfstar/
|
|
13
|
-
declare const InfoFieldUptimeTitle: import("@wolfstar/
|
|
14
|
-
declare const InfoFieldUptimeValue: import("@wolfstar/
|
|
10
|
+
declare const InfoName: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
11
|
+
declare const InfoDescription: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
12
|
+
declare const InfoEmbedDescription: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
13
|
+
declare const InfoFieldUptimeTitle: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
14
|
+
declare const InfoFieldUptimeValue: import("@wolfstar/plugin-i18next").TypedFT<{
|
|
15
15
|
host: string;
|
|
16
16
|
client: string;
|
|
17
17
|
}, string>;
|
|
18
|
-
declare const InfoFieldServerUsageTitle: import("@wolfstar/
|
|
19
|
-
declare const InfoFieldServerUsageValue: import("@wolfstar/
|
|
18
|
+
declare const InfoFieldServerUsageTitle: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
19
|
+
declare const InfoFieldServerUsageValue: import("@wolfstar/plugin-i18next").TypedFT<{
|
|
20
20
|
cpu: string;
|
|
21
21
|
heapUsed: string;
|
|
22
22
|
heapTotal: string;
|
|
23
23
|
}, string>;
|
|
24
|
-
declare const InfoButtonInvite: import("@wolfstar/
|
|
25
|
-
declare const InfoButtonSupport: import("@wolfstar/
|
|
26
|
-
declare const InfoButtonGitHub: import("@wolfstar/
|
|
27
|
-
declare const InfoButtonDonate: import("@wolfstar/
|
|
24
|
+
declare const InfoButtonInvite: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
25
|
+
declare const InfoButtonSupport: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
26
|
+
declare const InfoButtonGitHub: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
27
|
+
declare const InfoButtonDonate: import("@wolfstar/plugin-i18next").TypedT<string>;
|
|
28
28
|
declare namespace All_d_exports$1 {
|
|
29
29
|
export { Shared_d_exports as Shared };
|
|
30
30
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib/i18n/LanguageKeys/Commands/Shared.ts","../src/lib/i18n/LanguageKeys/Commands/All.ts","../src/lib/i18n/LanguageKeys/All.ts","../src/lib/information.ts","../src/lib/sentry.ts","../src/lib/utilities/register-command.ts"],"mappings":";;;;cAEa
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib/i18n/LanguageKeys/Commands/Shared.ts","../src/lib/i18n/LanguageKeys/Commands/All.ts","../src/lib/i18n/LanguageKeys/All.ts","../src/lib/information.ts","../src/lib/sentry.ts","../src/lib/utilities/register-command.ts"],"mappings":";;;;cAEa,+CAAU;cACV,sDAAiB;cACjB,mDAAc;EAAc;;cAC5B,6CAAQ;cACR,oDAAe;cACf,yDAAoB;cACpB,yDAAoB;cACpB,yDAAoB;EAAc;EAAgB;;cAClD,8DAAyB;cACzB,8DAAyB;EAAa;EAAkB;EAAmB;;cAC3E,qDAAgB;cAChB,sDAAiB;cACjB,qDAAgB;cAChB,qDAAgB;;;;;;;;;iBGZb,cAAc;iBAId;iBAIA,UAAU,kBAAkB;iBAI5B;;;iBCTA;iBAIA,iBAAiB,UAAS;UAwCzB,sBAAsB,KAAK,OAAO;EAClD,OAAO;;;;iBChDc,oBAAgB;;YAS3B;IACT"}
|
package/dist/index.js
CHANGED
|
@@ -1,115 +1,8 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { a as setInvite, i as getRepository, n as isSentryInitialized, o as setRepository, r as getInvite, s as All_exports, t as initializeSentry } from "./sentry-Dik0uTiq.js";
|
|
2
2
|
import * as Sentry from "@sentry/node";
|
|
3
|
-
import { FT, T } from "@wolfstar/http-framework-i18n";
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
5
|
-
import { resolve } from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
3
|
import { envIsDefined, envParseString } from "@wolfstar/env-utilities";
|
|
8
4
|
import { container } from "@wolfstar/http-framework";
|
|
9
5
|
|
|
10
|
-
//#region src/lib/i18n/LanguageKeys/Commands/Shared.ts
|
|
11
|
-
var Shared_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
-
DonateDescription: () => DonateDescription,
|
|
13
|
-
DonateName: () => DonateName,
|
|
14
|
-
DonateResponse: () => DonateResponse,
|
|
15
|
-
InfoButtonDonate: () => InfoButtonDonate,
|
|
16
|
-
InfoButtonGitHub: () => InfoButtonGitHub,
|
|
17
|
-
InfoButtonInvite: () => InfoButtonInvite,
|
|
18
|
-
InfoButtonSupport: () => InfoButtonSupport,
|
|
19
|
-
InfoDescription: () => InfoDescription,
|
|
20
|
-
InfoEmbedDescription: () => InfoEmbedDescription,
|
|
21
|
-
InfoFieldServerUsageTitle: () => InfoFieldServerUsageTitle,
|
|
22
|
-
InfoFieldServerUsageValue: () => InfoFieldServerUsageValue,
|
|
23
|
-
InfoFieldUptimeTitle: () => InfoFieldUptimeTitle,
|
|
24
|
-
InfoFieldUptimeValue: () => InfoFieldUptimeValue,
|
|
25
|
-
InfoName: () => InfoName
|
|
26
|
-
});
|
|
27
|
-
const DonateName = T("commands/shared:donateName");
|
|
28
|
-
const DonateDescription = T("commands/shared:donateDescription");
|
|
29
|
-
const DonateResponse = FT("commands/shared:donateResponse");
|
|
30
|
-
const InfoName = T("commands/shared:inviteName");
|
|
31
|
-
const InfoDescription = T("commands/shared:inviteDescription");
|
|
32
|
-
const InfoEmbedDescription = T("commands/shared:infoEmbedDescription");
|
|
33
|
-
const InfoFieldUptimeTitle = T("commands/shared:infoFieldUptimeTitle");
|
|
34
|
-
const InfoFieldUptimeValue = FT("commands/shared:infoFieldUptimeValue");
|
|
35
|
-
const InfoFieldServerUsageTitle = T("commands/shared:infoFieldServerUsageTitle");
|
|
36
|
-
const InfoFieldServerUsageValue = FT("commands/shared:infoFieldServerUsageValue");
|
|
37
|
-
const InfoButtonInvite = T("commands/shared:infoButtonInvite");
|
|
38
|
-
const InfoButtonSupport = T("commands/shared:infoButtonSupport");
|
|
39
|
-
const InfoButtonGitHub = T("commands/shared:infoButtonGitHub");
|
|
40
|
-
const InfoButtonDonate = T("commands/shared:infoButtonDonate");
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/lib/i18n/LanguageKeys/Commands/All.ts
|
|
44
|
-
var All_exports$1 = /* @__PURE__ */ __exportAll({ Shared: () => Shared_exports });
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/lib/i18n/LanguageKeys/All.ts
|
|
48
|
-
var All_exports = /* @__PURE__ */ __exportAll({ Commands: () => All_exports$1 });
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/lib/information.ts
|
|
52
|
-
let repository = process.env.CLIENT_REPOSITORY ?? "https://github.com/wolfstar-project";
|
|
53
|
-
let invite = process.env.CLIENT_INVITE ?? null;
|
|
54
|
-
function setRepository(url) {
|
|
55
|
-
repository = url.startsWith("http") ? url : `https://github.com/wolfstar-project/${url}`;
|
|
56
|
-
}
|
|
57
|
-
function getRepository() {
|
|
58
|
-
return repository;
|
|
59
|
-
}
|
|
60
|
-
function setInvite(clientId, permissions = "0") {
|
|
61
|
-
invite = `https://discord.com/oauth2/authorize?client_id=${clientId}&permissions=${permissions}&scope=bot%20applications.commands`;
|
|
62
|
-
}
|
|
63
|
-
function getInvite() {
|
|
64
|
-
return invite;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/lib/sentry.ts
|
|
69
|
-
let initialized = false;
|
|
70
|
-
function isSentryInitialized() {
|
|
71
|
-
return initialized;
|
|
72
|
-
}
|
|
73
|
-
function initializeSentry(options = {}) {
|
|
74
|
-
if (!process.env.SENTRY_DSN) return;
|
|
75
|
-
const extractedIntegrations = options.integrations ?? [];
|
|
76
|
-
const root = options.root ? typeof options.root === "string" ? options.root : fileURLToPath(options.root) : process.cwd();
|
|
77
|
-
Sentry.init({
|
|
78
|
-
dsn: process.env.SENTRY_DSN,
|
|
79
|
-
...options,
|
|
80
|
-
integrations: (integrations) => [
|
|
81
|
-
Sentry.consoleIntegration(),
|
|
82
|
-
Sentry.functionToStringIntegration(),
|
|
83
|
-
Sentry.linkedErrorsIntegration(),
|
|
84
|
-
Sentry.modulesIntegration(),
|
|
85
|
-
Sentry.onUncaughtExceptionIntegration(),
|
|
86
|
-
Sentry.onUnhandledRejectionIntegration(),
|
|
87
|
-
Sentry.rewriteFramesIntegration({ root }),
|
|
88
|
-
...typeof extractedIntegrations === "function" ? extractedIntegrations(integrations) : extractedIntegrations
|
|
89
|
-
]
|
|
90
|
-
});
|
|
91
|
-
const context = getAppContext();
|
|
92
|
-
if (context) Sentry.setContext("app", context);
|
|
93
|
-
initialized = true;
|
|
94
|
-
}
|
|
95
|
-
function getAppContext() {
|
|
96
|
-
if (process.env.npm_package_name && process.env.npm_package_version) return {
|
|
97
|
-
app_name: process.env.npm_package_name,
|
|
98
|
-
app_version: process.env.npm_package_version
|
|
99
|
-
};
|
|
100
|
-
try {
|
|
101
|
-
const path = process.env.npm_package_json ?? resolve("package.json");
|
|
102
|
-
const { name, version } = JSON.parse(readFileSync(path, "utf8"));
|
|
103
|
-
return {
|
|
104
|
-
app_name: name,
|
|
105
|
-
app_version: version
|
|
106
|
-
};
|
|
107
|
-
} catch {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
//#endregion
|
|
113
6
|
//#region src/lib/utilities/register-command.ts
|
|
114
7
|
async function registerCommands() {
|
|
115
8
|
if (envIsDefined("REGISTRY_GUILD_ID")) await container.applicationCommandRegistry.pushAllCommandsInGuild(envParseString("REGISTRY_GUILD_ID"));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/lib/
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/lib/utilities/register-command.ts"],"sourcesContent":["import { envIsDefined, envParseString } from '@wolfstar/env-utilities';\nimport { container } from '@wolfstar/http-framework';\n\nexport async function registerCommands() {\n\tif (envIsDefined('REGISTRY_GUILD_ID')) {\n\t\tawait container.applicationCommandRegistry.pushAllCommandsInGuild(envParseString('REGISTRY_GUILD_ID'));\n\t} else {\n\t\tawait container.applicationCommandRegistry.pushGlobalCommands();\n\t}\n}\n\ndeclare module '@wolfstar/env-utilities' {\n\tinterface Env {\n\t\tREGISTRY_GUILD_ID: string;\n\t}\n}\n"],"mappings":";;;;;;AAGA,eAAsB,mBAAmB;CACxC,IAAI,aAAa,mBAAmB,GACnC,MAAM,UAAU,2BAA2B,uBAAuB,eAAe,mBAAmB,CAAC;MAErG,MAAM,UAAU,2BAA2B,mBAAmB;AAEhE"}
|
package/dist/register.d.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import "@wolfstar/http-framework";
|
|
1
|
+
import { Command, Listener } from "@wolfstar/http-framework";
|
|
2
|
+
//#region src/register.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Path pattern for this package's bundled locales, in the format
|
|
5
|
+
* `@wolfstar/plugin-i18next` expects for `i18n.backend.paths`.
|
|
6
|
+
*/
|
|
7
|
+
declare const localesPath: string;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { localesPath };
|
|
10
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","names":[],"sources":["../src/register.ts"],"mappings":";;;;;;cAUa"}
|
package/dist/register.js
CHANGED
|
@@ -1,8 +1,229 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as InfoButtonDonate, d as InfoButtonSupport, f as InfoEmbedDescription, g as InfoFieldUptimeValue, h as InfoFieldUptimeTitle, i as getRepository, l as InfoButtonGitHub, m as InfoFieldServerUsageValue, n as isSentryInitialized, p as InfoFieldServerUsageTitle, r as getInvite, u as InfoButtonInvite } from "./sentry-Dik0uTiq.js";
|
|
2
|
+
import { captureException } from "@sentry/node";
|
|
3
|
+
import { applyLocalizedBuilder, getSupportedUserLanguageName, getSupportedUserLanguageT } from "@wolfstar/plugin-i18next";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { Client, Command, Listener, RegisterCommand, container } from "@wolfstar/http-framework";
|
|
7
|
+
import { EmbedBuilder, TimestampStyles, time } from "@discordjs/builders";
|
|
8
|
+
import { ButtonStyle, ComponentType, MessageFlags } from "discord-api-types/v10";
|
|
9
|
+
import { cpus, uptime } from "node:os";
|
|
2
10
|
|
|
11
|
+
//#region \0@oxc-project+runtime@0.144.0/helpers/esm/decorate.js
|
|
12
|
+
function __decorate(decorators, target, key, desc) {
|
|
13
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
15
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
16
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/commands/info.ts
|
|
21
|
+
var _SharedCommand;
|
|
22
|
+
let SharedCommand = _SharedCommand = class SharedCommand extends Command {
|
|
23
|
+
chatInputRun(interaction) {
|
|
24
|
+
const t = getSupportedUserLanguageT(interaction);
|
|
25
|
+
const locale = getSupportedUserLanguageName(interaction);
|
|
26
|
+
const embed = new EmbedBuilder().setDescription(t(InfoEmbedDescription)).addFields(this.getUptimeStatistics(t), this.getServerUsageStatistics(t, locale));
|
|
27
|
+
const components = this.getComponents(t);
|
|
28
|
+
return interaction.reply({
|
|
29
|
+
embeds: [embed.toJSON()],
|
|
30
|
+
components,
|
|
31
|
+
flags: MessageFlags.Ephemeral
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
getUptimeStatistics(t) {
|
|
35
|
+
const nowSeconds = Math.round(Date.now() / 1e3);
|
|
36
|
+
return {
|
|
37
|
+
name: t(InfoFieldUptimeTitle),
|
|
38
|
+
value: t(InfoFieldUptimeValue, {
|
|
39
|
+
host: time(Math.round(nowSeconds - uptime()), TimestampStyles.RelativeTime),
|
|
40
|
+
client: time(Math.round(nowSeconds - process.uptime()), TimestampStyles.RelativeTime)
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
getServerUsageStatistics(t, locale) {
|
|
45
|
+
const usage = process.memoryUsage();
|
|
46
|
+
return {
|
|
47
|
+
name: t(InfoFieldServerUsageTitle),
|
|
48
|
+
value: t(InfoFieldServerUsageValue, {
|
|
49
|
+
cpu: cpus().map(_SharedCommand.formatCpuInfo.bind(null)).join(" | "),
|
|
50
|
+
heapUsed: (usage.heapUsed / 1048576).toLocaleString(locale, { maximumFractionDigits: 2 }),
|
|
51
|
+
heapTotal: (usage.heapTotal / 1048576).toLocaleString(locale, { maximumFractionDigits: 2 })
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
getComponents(t) {
|
|
56
|
+
const url = getInvite();
|
|
57
|
+
const support = this.getSupportComponent(t);
|
|
58
|
+
const github = this.getGitHubComponent(t);
|
|
59
|
+
const donate = this.getDonateComponent(t);
|
|
60
|
+
return url ? [this.getActionRow(support, this.getInviteComponent(t, url)), this.getActionRow(github, donate)] : [this.getActionRow(support, github, donate)];
|
|
61
|
+
}
|
|
62
|
+
getActionRow(...components) {
|
|
63
|
+
return {
|
|
64
|
+
type: ComponentType.ActionRow,
|
|
65
|
+
components
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
getSupportComponent(t) {
|
|
69
|
+
return {
|
|
70
|
+
type: ComponentType.Button,
|
|
71
|
+
style: ButtonStyle.Link,
|
|
72
|
+
label: t(InfoButtonSupport),
|
|
73
|
+
emoji: { name: "🆘" },
|
|
74
|
+
url: "https://discord.gg/6gakFR2"
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
getInviteComponent(t, url) {
|
|
78
|
+
return {
|
|
79
|
+
type: ComponentType.Button,
|
|
80
|
+
style: ButtonStyle.Link,
|
|
81
|
+
label: t(InfoButtonInvite),
|
|
82
|
+
emoji: { name: "🎉" },
|
|
83
|
+
url
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
getGitHubComponent(t) {
|
|
87
|
+
return {
|
|
88
|
+
type: ComponentType.Button,
|
|
89
|
+
style: ButtonStyle.Link,
|
|
90
|
+
label: t(InfoButtonGitHub),
|
|
91
|
+
emoji: {
|
|
92
|
+
id: "950888087188283422",
|
|
93
|
+
name: "github2"
|
|
94
|
+
},
|
|
95
|
+
url: getRepository()
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
getDonateComponent(t) {
|
|
99
|
+
return {
|
|
100
|
+
type: ComponentType.Button,
|
|
101
|
+
style: ButtonStyle.Link,
|
|
102
|
+
label: t(InfoButtonDonate),
|
|
103
|
+
emoji: { name: "🧡" },
|
|
104
|
+
url: "https://donate.wolfstar.rocks"
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
static formatCpuInfo({ times }) {
|
|
108
|
+
return `${Math.round((times.user + times.nice + times.sys + times.irq) / times.idle * 1e4) / 100}%`;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
SharedCommand = _SharedCommand = __decorate([RegisterCommand((builder) => applyLocalizedBuilder(builder, "commands/shared:info"))], SharedCommand);
|
|
112
|
+
container.stores.loadPiece({
|
|
113
|
+
name: "info",
|
|
114
|
+
piece: SharedCommand,
|
|
115
|
+
store: "commands"
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/listeners/SharedAutocompleteError.ts
|
|
120
|
+
var SharedListener$3 = class extends Listener {
|
|
121
|
+
constructor(context, options) {
|
|
122
|
+
super(context, {
|
|
123
|
+
...options,
|
|
124
|
+
event: "autocompleteError",
|
|
125
|
+
enabled: isSentryInitialized()
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
run(error, context) {
|
|
129
|
+
captureException(error, (scope) => scope.setLevel("error").setTag("event", this.name).setExtra("command", context.command.name));
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
container.stores.loadPiece({
|
|
133
|
+
name: "SharedAutocompleteError",
|
|
134
|
+
piece: SharedListener$3,
|
|
135
|
+
store: "listeners"
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/listeners/SharedCommandError.ts
|
|
140
|
+
var SharedListener$2 = class extends Listener {
|
|
141
|
+
constructor(context, options) {
|
|
142
|
+
super(context, {
|
|
143
|
+
...options,
|
|
144
|
+
event: "commandError",
|
|
145
|
+
enabled: isSentryInitialized()
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
run(error, context) {
|
|
149
|
+
captureException(error, (scope) => scope.setLevel("error").setTag("event", this.name).setExtra("command", context.command.name));
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
container.stores.loadPiece({
|
|
153
|
+
name: "SharedCommandError",
|
|
154
|
+
piece: SharedListener$2,
|
|
155
|
+
store: "listeners"
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/listeners/SharedError.ts
|
|
160
|
+
var SharedListener$1 = class extends Listener {
|
|
161
|
+
constructor(context, options) {
|
|
162
|
+
super(context, {
|
|
163
|
+
...options,
|
|
164
|
+
event: "error",
|
|
165
|
+
enabled: isSentryInitialized()
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
run(error) {
|
|
169
|
+
captureException(error, (scope) => scope.setLevel("error").setTag("event", this.name));
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
container.stores.loadPiece({
|
|
173
|
+
name: "SharedError",
|
|
174
|
+
piece: SharedListener$1,
|
|
175
|
+
store: "listeners"
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/listeners/SharedInteractionHandlerError.ts
|
|
180
|
+
var SharedListener = class extends Listener {
|
|
181
|
+
constructor(context, options) {
|
|
182
|
+
super(context, {
|
|
183
|
+
...options,
|
|
184
|
+
event: "interactionHandlerError",
|
|
185
|
+
enabled: isSentryInitialized()
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
run(error, context) {
|
|
189
|
+
captureException(error, (scope) => scope.setLevel("error").setTag("event", this.name).setExtra("handler", context.handler.name));
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
container.stores.loadPiece({
|
|
193
|
+
name: "SharedInteractionHandlerError",
|
|
194
|
+
piece: SharedListener,
|
|
195
|
+
store: "listeners"
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
3
199
|
//#region src/register.ts
|
|
4
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Path pattern for this package's bundled locales, in the format
|
|
202
|
+
* `@wolfstar/plugin-i18next` expects for `i18n.backend.paths`.
|
|
203
|
+
*/
|
|
204
|
+
const localesPath = join(fileURLToPath(new URL("../src/locales", import.meta.url)), "{{lng}}", "{{ns}}.json");
|
|
205
|
+
/**
|
|
206
|
+
* `@wolfstar/plugin-i18next` reads `Client`'s `i18n` option exactly once, in its own
|
|
207
|
+
* `preGenericsInitialization` hook, and has no API to register extra locale directories
|
|
208
|
+
* afterwards. Hooks run in registration order, so registering this one *before* importing
|
|
209
|
+
* the plugin's `register` entrypoint below guarantees it runs first and can splice this
|
|
210
|
+
* package's locales into `options.i18n.backend.paths` before the plugin builds its
|
|
211
|
+
* `InternationalizationHandler` — consumers that only import this module keep working
|
|
212
|
+
* without having to list `localesPath` in their own `Client` config.
|
|
213
|
+
*/
|
|
214
|
+
Client.plugins.registerPreGenericsInitializationHook((options) => {
|
|
215
|
+
const { i18n } = options;
|
|
216
|
+
if (!i18n) return;
|
|
217
|
+
options.i18n = {
|
|
218
|
+
...i18n,
|
|
219
|
+
backend: {
|
|
220
|
+
...i18n.backend,
|
|
221
|
+
paths: [...i18n.backend?.paths ?? [], localesPath]
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}, "@wolfstar/shared-http-pieces");
|
|
225
|
+
await import("@wolfstar/plugin-i18next/register");
|
|
5
226
|
|
|
6
227
|
//#endregion
|
|
7
|
-
export {
|
|
228
|
+
export { localesPath };
|
|
8
229
|
//# sourceMappingURL=register.js.map
|
package/dist/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","names":[],"sources":["../src/register.ts"],"sourcesContent":["import { load } from '@wolfstar/http-framework-i18n';\nimport './commands/_load.js';\nimport './listeners/_load.js';\n\nawait load(new URL('../src/locales', import.meta.url));\n"],"mappings":";;;AAIA,MAAM,KAAK,IAAI,IAAI,kBAAkB,YAAY,GAAG,CAAC"}
|
|
1
|
+
{"version":3,"file":"register.js","names":["LanguageKeys.Commands.Shared.InfoEmbedDescription","LanguageKeys.Commands.Shared.InfoFieldUptimeTitle","LanguageKeys.Commands.Shared.InfoFieldUptimeValue","LanguageKeys.Commands.Shared.InfoFieldServerUsageTitle","LanguageKeys.Commands.Shared.InfoFieldServerUsageValue","LanguageKeys.Commands.Shared.InfoButtonSupport","LanguageKeys.Commands.Shared.InfoButtonInvite","LanguageKeys.Commands.Shared.InfoButtonGitHub","LanguageKeys.Commands.Shared.InfoButtonDonate","SharedListener","SharedListener","SharedListener"],"sources":["../src/commands/info.ts","../src/listeners/SharedAutocompleteError.ts","../src/listeners/SharedCommandError.ts","../src/listeners/SharedError.ts","../src/listeners/SharedInteractionHandlerError.ts","../src/register.ts"],"sourcesContent":["import { EmbedBuilder, time, TimestampStyles } from '@discordjs/builders';\nimport { Command, container, RegisterCommand } from '@wolfstar/http-framework';\nimport { applyLocalizedBuilder, getSupportedUserLanguageName, getSupportedUserLanguageT, type TFunction } from '@wolfstar/plugin-i18next';\nimport {\n\tButtonStyle,\n\tComponentType,\n\tMessageFlags,\n\ttype APIActionRowComponent,\n\ttype APIComponentInMessageActionRow,\n\ttype APIEmbedField\n} from 'discord-api-types/v10';\nimport { cpus, uptime, type CpuInfo } from 'node:os';\nimport { LanguageKeys } from '../lib/i18n/LanguageKeys.js';\nimport { getInvite, getRepository } from '../lib/information.js';\n\n@RegisterCommand((builder) => applyLocalizedBuilder(builder, 'commands/shared:info'))\nexport class SharedCommand extends Command {\n\tpublic override chatInputRun(interaction: Command.ChatInputInteraction) {\n\t\tconst t = getSupportedUserLanguageT(interaction);\n\t\tconst locale = getSupportedUserLanguageName(interaction);\n\t\tconst embed = new EmbedBuilder()\n\t\t\t.setDescription(t(LanguageKeys.Commands.Shared.InfoEmbedDescription))\n\t\t\t.addFields(this.getUptimeStatistics(t), this.getServerUsageStatistics(t, locale));\n\t\tconst components = this.getComponents(t);\n\n\t\treturn interaction.reply({ embeds: [embed.toJSON()], components, flags: MessageFlags.Ephemeral });\n\t}\n\n\tprivate getUptimeStatistics(t: TFunction): APIEmbedField {\n\t\tconst now = Date.now();\n\t\tconst nowSeconds = Math.round(now / 1000);\n\n\t\treturn {\n\t\t\tname: t(LanguageKeys.Commands.Shared.InfoFieldUptimeTitle),\n\t\t\tvalue: t(LanguageKeys.Commands.Shared.InfoFieldUptimeValue, {\n\t\t\t\thost: time(Math.round(nowSeconds - uptime()), TimestampStyles.RelativeTime),\n\t\t\t\tclient: time(Math.round(nowSeconds - process.uptime()), TimestampStyles.RelativeTime)\n\t\t\t})\n\t\t};\n\t}\n\n\tprivate getServerUsageStatistics(t: TFunction, locale: string): APIEmbedField {\n\t\tconst usage = process.memoryUsage();\n\n\t\treturn {\n\t\t\tname: t(LanguageKeys.Commands.Shared.InfoFieldServerUsageTitle),\n\t\t\tvalue: t(LanguageKeys.Commands.Shared.InfoFieldServerUsageValue, {\n\t\t\t\tcpu: cpus().map(SharedCommand.formatCpuInfo.bind(null)).join(' | '),\n\t\t\t\theapUsed: (usage.heapUsed / 1048576).toLocaleString(locale, { maximumFractionDigits: 2 }),\n\t\t\t\theapTotal: (usage.heapTotal / 1048576).toLocaleString(locale, { maximumFractionDigits: 2 })\n\t\t\t})\n\t\t};\n\t}\n\n\tprivate getComponents(t: TFunction) {\n\t\tconst url = getInvite();\n\t\tconst support = this.getSupportComponent(t);\n\t\tconst github = this.getGitHubComponent(t);\n\t\tconst donate = this.getDonateComponent(t);\n\t\tconst data = url\n\t\t\t? [this.getActionRow(support, this.getInviteComponent(t, url)), this.getActionRow(github, donate)]\n\t\t\t: [this.getActionRow(support, github, donate)];\n\n\t\treturn data;\n\t}\n\n\tprivate getActionRow(...components: APIComponentInMessageActionRow[]): APIActionRowComponent<APIComponentInMessageActionRow> {\n\t\treturn { type: ComponentType.ActionRow, components };\n\t}\n\n\tprivate getSupportComponent(t: TFunction): APIComponentInMessageActionRow {\n\t\treturn {\n\t\t\ttype: ComponentType.Button,\n\t\t\tstyle: ButtonStyle.Link,\n\t\t\tlabel: t(LanguageKeys.Commands.Shared.InfoButtonSupport),\n\t\t\temoji: { name: '🆘' },\n\t\t\turl: 'https://discord.gg/6gakFR2'\n\t\t};\n\t}\n\n\tprivate getInviteComponent(t: TFunction, url: string): APIComponentInMessageActionRow {\n\t\treturn {\n\t\t\ttype: ComponentType.Button,\n\t\t\tstyle: ButtonStyle.Link,\n\t\t\tlabel: t(LanguageKeys.Commands.Shared.InfoButtonInvite),\n\t\t\temoji: { name: '🎉' },\n\t\t\turl\n\t\t};\n\t}\n\n\tprivate getGitHubComponent(t: TFunction): APIComponentInMessageActionRow {\n\t\treturn {\n\t\t\ttype: ComponentType.Button,\n\t\t\tstyle: ButtonStyle.Link,\n\t\t\tlabel: t(LanguageKeys.Commands.Shared.InfoButtonGitHub),\n\t\t\temoji: { id: '950888087188283422', name: 'github2' },\n\t\t\turl: getRepository()\n\t\t};\n\t}\n\n\tprivate getDonateComponent(t: TFunction): APIComponentInMessageActionRow {\n\t\treturn {\n\t\t\ttype: ComponentType.Button,\n\t\t\tstyle: ButtonStyle.Link,\n\t\t\tlabel: t(LanguageKeys.Commands.Shared.InfoButtonDonate),\n\t\t\temoji: { name: '🧡' },\n\t\t\turl: 'https://donate.wolfstar.rocks'\n\t\t};\n\t}\n\n\tprivate static formatCpuInfo({ times }: CpuInfo) {\n\t\treturn `${Math.round(((times.user + times.nice + times.sys + times.irq) / times.idle) * 10000) / 100}%`;\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'info', piece: SharedCommand as any, store: 'commands' });\n","import { captureException } from '@sentry/node';\nimport { Listener, container, type ClientEventAutocompleteContext, type ClientEvents } from '@wolfstar/http-framework';\nimport { isSentryInitialized } from '../lib/sentry.js';\n\nexport class SharedListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext, options: Listener.Options) {\n\t\tsuper(context, { ...options, event: 'autocompleteError' satisfies keyof ClientEvents, enabled: isSentryInitialized() });\n\t}\n\n\tpublic run(error: unknown, context: ClientEventAutocompleteContext) {\n\t\tcaptureException(error, (scope) => scope.setLevel('error').setTag('event', this.name).setExtra('command', context.command.name));\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'SharedAutocompleteError', piece: SharedListener as any, store: 'listeners' });\n","import { captureException } from '@sentry/node';\nimport { Listener, container, type ClientEventCommandContext, type ClientEvents } from '@wolfstar/http-framework';\nimport { isSentryInitialized } from '../lib/sentry.js';\n\nexport class SharedListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext, options: Listener.Options) {\n\t\tsuper(context, { ...options, event: 'commandError' satisfies keyof ClientEvents, enabled: isSentryInitialized() });\n\t}\n\n\tpublic run(error: unknown, context: ClientEventCommandContext) {\n\t\tcaptureException(error, (scope) => scope.setLevel('error').setTag('event', this.name).setExtra('command', context.command.name));\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'SharedCommandError', piece: SharedListener as any, store: 'listeners' });\n","import { captureException } from '@sentry/node';\nimport { Listener, container, type ClientEvents } from '@wolfstar/http-framework';\nimport { isSentryInitialized } from '../lib/sentry.js';\n\nexport class SharedListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext, options: Listener.Options) {\n\t\tsuper(context, { ...options, event: 'error' satisfies keyof ClientEvents, enabled: isSentryInitialized() });\n\t}\n\n\tpublic run(error: unknown) {\n\t\tcaptureException(error, (scope) => scope.setLevel('error').setTag('event', this.name));\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'SharedError', piece: SharedListener as any, store: 'listeners' });\n","import { captureException } from '@sentry/node';\nimport { Listener, container, type ClientEventInteractionHandlerContext, type ClientEvents } from '@wolfstar/http-framework';\nimport { isSentryInitialized } from '../lib/sentry.js';\n\nexport class SharedListener extends Listener {\n\tpublic constructor(context: Listener.LoaderContext, options: Listener.Options) {\n\t\tsuper(context, { ...options, event: 'interactionHandlerError' satisfies keyof ClientEvents, enabled: isSentryInitialized() });\n\t}\n\n\tpublic run(error: unknown, context: ClientEventInteractionHandlerContext) {\n\t\tcaptureException(error, (scope) => scope.setLevel('error').setTag('event', this.name).setExtra('handler', context.handler.name));\n\t}\n}\n\nvoid container.stores.loadPiece({ name: 'SharedInteractionHandlerError', piece: SharedListener as any, store: 'listeners' });\n","import { Client } from '@wolfstar/http-framework';\nimport { join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport './commands/_load.js';\nimport './listeners/_load.js';\n\n/**\n * Path pattern for this package's bundled locales, in the format\n * `@wolfstar/plugin-i18next` expects for `i18n.backend.paths`.\n */\nexport const localesPath = join(fileURLToPath(new URL('../src/locales', import.meta.url)), '{{lng}}', '{{ns}}.json');\n\n/**\n * `@wolfstar/plugin-i18next` reads `Client`'s `i18n` option exactly once, in its own\n * `preGenericsInitialization` hook, and has no API to register extra locale directories\n * afterwards. Hooks run in registration order, so registering this one *before* importing\n * the plugin's `register` entrypoint below guarantees it runs first and can splice this\n * package's locales into `options.i18n.backend.paths` before the plugin builds its\n * `InternationalizationHandler` — consumers that only import this module keep working\n * without having to list `localesPath` in their own `Client` config.\n */\nClient.plugins.registerPreGenericsInitializationHook((options) => {\n\tconst { i18n } = options;\n\tif (!i18n) return;\n\toptions.i18n = { ...i18n, backend: { ...i18n.backend, paths: [...(i18n.backend?.paths ?? []), localesPath] } };\n}, '@wolfstar/shared-http-pieces');\n\n// A dynamic import, not a static one: static imports are hoisted above the hook\n// registration above, which would let the plugin's own hook register — and run — first.\nawait import('@wolfstar/plugin-i18next/register');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,iCAAN,MAAM,sBAAsB,QAAQ;CAC1C,AAAgB,aAAa,aAA2C;EACvE,MAAM,IAAI,0BAA0B,WAAW;EAC/C,MAAM,SAAS,6BAA6B,WAAW;EACvD,MAAM,QAAQ,IAAI,aAAa,CAAC,CAC9B,eAAe,EAAEA,oBAAiD,CAAC,CAAC,CACpE,UAAU,KAAK,oBAAoB,CAAC,GAAG,KAAK,yBAAyB,GAAG,MAAM,CAAC;EACjF,MAAM,aAAa,KAAK,cAAc,CAAC;EAEvC,OAAO,YAAY,MAAM;GAAE,QAAQ,CAAC,MAAM,OAAO,CAAC;GAAG;GAAY,OAAO,aAAa;EAAU,CAAC;CACjG;CAEA,AAAQ,oBAAoB,GAA6B;EAExD,MAAM,aAAa,KAAK,MADZ,KAAK,IACe,IAAI,GAAI;EAExC,OAAO;GACN,MAAM,EAAEC,oBAAiD;GACzD,OAAO,EAAEC,sBAAmD;IAC3D,MAAM,KAAK,KAAK,MAAM,aAAa,OAAO,CAAC,GAAG,gBAAgB,YAAY;IAC1E,QAAQ,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AC,GAAI,WAAW;EAAE;CAAE;AAC9G,GAAG,8BAA8B;AAIjC,MAAM,OAAO"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-w6R9maHv.js";
|
|
2
|
+
import * as Sentry from "@sentry/node";
|
|
3
|
+
import { FT, T } from "@wolfstar/plugin-i18next";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
//#region src/lib/i18n/LanguageKeys/Commands/Shared.ts
|
|
9
|
+
var Shared_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
DonateDescription: () => DonateDescription,
|
|
11
|
+
DonateName: () => DonateName,
|
|
12
|
+
DonateResponse: () => DonateResponse,
|
|
13
|
+
InfoButtonDonate: () => InfoButtonDonate,
|
|
14
|
+
InfoButtonGitHub: () => InfoButtonGitHub,
|
|
15
|
+
InfoButtonInvite: () => InfoButtonInvite,
|
|
16
|
+
InfoButtonSupport: () => InfoButtonSupport,
|
|
17
|
+
InfoDescription: () => InfoDescription,
|
|
18
|
+
InfoEmbedDescription: () => InfoEmbedDescription,
|
|
19
|
+
InfoFieldServerUsageTitle: () => InfoFieldServerUsageTitle,
|
|
20
|
+
InfoFieldServerUsageValue: () => InfoFieldServerUsageValue,
|
|
21
|
+
InfoFieldUptimeTitle: () => InfoFieldUptimeTitle,
|
|
22
|
+
InfoFieldUptimeValue: () => InfoFieldUptimeValue,
|
|
23
|
+
InfoName: () => InfoName
|
|
24
|
+
});
|
|
25
|
+
const DonateName = T("commands/shared:donateName");
|
|
26
|
+
const DonateDescription = T("commands/shared:donateDescription");
|
|
27
|
+
const DonateResponse = FT("commands/shared:donateResponse");
|
|
28
|
+
const InfoName = T("commands/shared:inviteName");
|
|
29
|
+
const InfoDescription = T("commands/shared:inviteDescription");
|
|
30
|
+
const InfoEmbedDescription = T("commands/shared:infoEmbedDescription");
|
|
31
|
+
const InfoFieldUptimeTitle = T("commands/shared:infoFieldUptimeTitle");
|
|
32
|
+
const InfoFieldUptimeValue = FT("commands/shared:infoFieldUptimeValue");
|
|
33
|
+
const InfoFieldServerUsageTitle = T("commands/shared:infoFieldServerUsageTitle");
|
|
34
|
+
const InfoFieldServerUsageValue = FT("commands/shared:infoFieldServerUsageValue");
|
|
35
|
+
const InfoButtonInvite = T("commands/shared:infoButtonInvite");
|
|
36
|
+
const InfoButtonSupport = T("commands/shared:infoButtonSupport");
|
|
37
|
+
const InfoButtonGitHub = T("commands/shared:infoButtonGitHub");
|
|
38
|
+
const InfoButtonDonate = T("commands/shared:infoButtonDonate");
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/lib/i18n/LanguageKeys/Commands/All.ts
|
|
42
|
+
var All_exports$1 = /* @__PURE__ */ __exportAll({ Shared: () => Shared_exports });
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/lib/i18n/LanguageKeys/All.ts
|
|
46
|
+
var All_exports = /* @__PURE__ */ __exportAll({ Commands: () => All_exports$1 });
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/lib/information.ts
|
|
50
|
+
let repository = process.env.CLIENT_REPOSITORY ?? "https://github.com/wolfstar-project";
|
|
51
|
+
let invite = process.env.CLIENT_INVITE ?? null;
|
|
52
|
+
function setRepository(url) {
|
|
53
|
+
repository = url.startsWith("http") ? url : `https://github.com/wolfstar-project/${url}`;
|
|
54
|
+
}
|
|
55
|
+
function getRepository() {
|
|
56
|
+
return repository;
|
|
57
|
+
}
|
|
58
|
+
function setInvite(clientId, permissions = "0") {
|
|
59
|
+
invite = `https://discord.com/oauth2/authorize?client_id=${clientId}&permissions=${permissions}&scope=bot%20applications.commands`;
|
|
60
|
+
}
|
|
61
|
+
function getInvite() {
|
|
62
|
+
return invite;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/lib/sentry.ts
|
|
67
|
+
let initialized = false;
|
|
68
|
+
function isSentryInitialized() {
|
|
69
|
+
return initialized;
|
|
70
|
+
}
|
|
71
|
+
function initializeSentry(options = {}) {
|
|
72
|
+
if (!process.env.SENTRY_DSN) return;
|
|
73
|
+
const extractedIntegrations = options.integrations ?? [];
|
|
74
|
+
const root = options.root ? typeof options.root === "string" ? options.root : fileURLToPath(options.root) : process.cwd();
|
|
75
|
+
Sentry.init({
|
|
76
|
+
dsn: process.env.SENTRY_DSN,
|
|
77
|
+
...options,
|
|
78
|
+
integrations: (integrations) => [
|
|
79
|
+
Sentry.consoleIntegration(),
|
|
80
|
+
Sentry.functionToStringIntegration(),
|
|
81
|
+
Sentry.linkedErrorsIntegration(),
|
|
82
|
+
Sentry.modulesIntegration(),
|
|
83
|
+
Sentry.onUncaughtExceptionIntegration(),
|
|
84
|
+
Sentry.onUnhandledRejectionIntegration(),
|
|
85
|
+
Sentry.rewriteFramesIntegration({ root }),
|
|
86
|
+
...typeof extractedIntegrations === "function" ? extractedIntegrations(integrations) : extractedIntegrations
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
const context = getAppContext();
|
|
90
|
+
if (context) Sentry.setContext("app", context);
|
|
91
|
+
initialized = true;
|
|
92
|
+
}
|
|
93
|
+
function getAppContext() {
|
|
94
|
+
if (process.env.npm_package_name && process.env.npm_package_version) return {
|
|
95
|
+
app_name: process.env.npm_package_name,
|
|
96
|
+
app_version: process.env.npm_package_version
|
|
97
|
+
};
|
|
98
|
+
try {
|
|
99
|
+
const path = process.env.npm_package_json ?? resolve("package.json");
|
|
100
|
+
const { name, version } = JSON.parse(readFileSync(path, "utf8"));
|
|
101
|
+
return {
|
|
102
|
+
app_name: name,
|
|
103
|
+
app_version: version
|
|
104
|
+
};
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
export { setInvite as a, InfoButtonDonate as c, InfoButtonSupport as d, InfoEmbedDescription as f, InfoFieldUptimeValue as g, InfoFieldUptimeTitle as h, getRepository as i, InfoButtonGitHub as l, InfoFieldServerUsageValue as m, isSentryInitialized as n, setRepository as o, InfoFieldServerUsageTitle as p, getInvite as r, All_exports as s, initializeSentry as t, InfoButtonInvite as u };
|
|
112
|
+
//# sourceMappingURL=sentry-Dik0uTiq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentry-Dik0uTiq.js","names":[],"sources":["../src/lib/i18n/LanguageKeys/Commands/Shared.ts","../src/lib/i18n/LanguageKeys/Commands/All.ts","../src/lib/i18n/LanguageKeys/All.ts","../src/lib/information.ts","../src/lib/sentry.ts"],"sourcesContent":["import { FT, T } from '@wolfstar/plugin-i18next';\n\nexport const DonateName = T('commands/shared:donateName');\nexport const DonateDescription = T('commands/shared:donateDescription');\nexport const DonateResponse = FT<{ urls: string }>('commands/shared:donateResponse');\nexport const InfoName = T('commands/shared:inviteName');\nexport const InfoDescription = T('commands/shared:inviteDescription');\nexport const InfoEmbedDescription = T('commands/shared:infoEmbedDescription');\nexport const InfoFieldUptimeTitle = T('commands/shared:infoFieldUptimeTitle');\nexport const InfoFieldUptimeValue = FT<{ host: string; client: string }>('commands/shared:infoFieldUptimeValue');\nexport const InfoFieldServerUsageTitle = T('commands/shared:infoFieldServerUsageTitle');\nexport const InfoFieldServerUsageValue = FT<{ cpu: string; heapUsed: string; heapTotal: string }>('commands/shared:infoFieldServerUsageValue');\nexport const InfoButtonInvite = T('commands/shared:infoButtonInvite');\nexport const InfoButtonSupport = T('commands/shared:infoButtonSupport');\nexport const InfoButtonGitHub = T('commands/shared:infoButtonGitHub');\nexport const InfoButtonDonate = T('commands/shared:infoButtonDonate');\n","export * as Shared from './Shared.js';\n","export * as Commands from './Commands/All.js';\n","let repository = process.env.CLIENT_REPOSITORY ?? 'https://github.com/wolfstar-project';\nlet invite = process.env.CLIENT_INVITE ?? null;\n\nexport function setRepository(url: string) {\n\trepository = url.startsWith('http') ? url : `https://github.com/wolfstar-project/${url}`;\n}\n\nexport function getRepository() {\n\treturn repository;\n}\n\nexport function setInvite(clientId: string, permissions = '0') {\n\tinvite = `https://discord.com/oauth2/authorize?client_id=${clientId}&permissions=${permissions}&scope=bot%20applications.commands`;\n}\n\nexport function getInvite() {\n\treturn invite;\n}\n","import * as Sentry from '@sentry/node';\nimport { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nlet initialized = false;\nexport function isSentryInitialized() {\n\treturn initialized;\n}\n\nexport function initializeSentry(options: SentryOptions = {}) {\n\tif (!process.env.SENTRY_DSN) return;\n\n\tconst extractedIntegrations = options.integrations ?? [];\n\tconst root = options.root ? (typeof options.root === 'string' ? options.root : fileURLToPath(options.root)) : process.cwd();\n\tSentry.init({\n\t\tdsn: process.env.SENTRY_DSN,\n\t\t...options,\n\t\tintegrations: (integrations) => [\n\t\t\tSentry.consoleIntegration(),\n\t\t\tSentry.functionToStringIntegration(),\n\t\t\tSentry.linkedErrorsIntegration(),\n\t\t\tSentry.modulesIntegration(),\n\t\t\tSentry.onUncaughtExceptionIntegration(),\n\t\t\tSentry.onUnhandledRejectionIntegration(),\n\t\t\tSentry.rewriteFramesIntegration({ root }),\n\t\t\t...(typeof extractedIntegrations === 'function' ? extractedIntegrations(integrations) : extractedIntegrations)\n\t\t]\n\t});\n\n\tconst context = getAppContext();\n\tif (context) Sentry.setContext('app', context);\n\n\tinitialized = true;\n}\n\nfunction getAppContext() {\n\tif (process.env.npm_package_name && process.env.npm_package_version) {\n\t\treturn { app_name: process.env.npm_package_name, app_version: process.env.npm_package_version };\n\t}\n\n\ttry {\n\t\tconst path = process.env.npm_package_json ?? resolve('package.json');\n\t\tconst { name, version } = JSON.parse(readFileSync(path, 'utf8')) as { name: string; version: string };\n\t\treturn { app_name: name, app_version: version };\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport interface SentryOptions extends Omit<Sentry.NodeO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IAAI;EACjB,GAAG;EACH,eAAe,iBAAiB;GAC/B,OAAO,mBAAmB;GAC1B,OAAO,4BAA4B;GACnC,OAAO,wBAAwB;GAC/B,OAAO,mBAAmB;GAC1B,OAAO,+BAA+B;GACtC,OAAO,gCAAgC;GACvC,OAAO,yBAAyB,EAAE,KAAK,CAAC;GACxC,GAAI,OAAO,0BAA0B,aAAa,sBAAsB,YAAY,IAAI;EACzF;CACD,CAAC;CAED,MAAM,UAAU,cAAc;CAC9B,IAAI,SAAS,OAAO,WAAW,OAAO,OAAO;CAE7C,cAAc;AACf;AAEA,SAAS,gBAAgB;CACxB,IAAI,QAAQ,IAAI,oBAAoB,QAAQ,IAAI,qBAC/C,OAAO;EAAE,UAAU,QAAQ,IAAI;EAAkB,aAAa,QAAQ,IAAI;CAAoB;CAG/F,IAAI;EACH,MAAM,OAAO,QAAQ,IAAI,oBAAoB,QAAQ,cAAc;EACnE,MAAM,EAAE,MAAM,YAAY,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;EAC/D,OAAO;GAAE,UAAU;GAAM,aAAa;EAAQ;CAC/C,QAAQ;EACP,OAAO;CACR;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wolfstar/shared-http-pieces",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10-next-20260829215854",
|
|
4
4
|
"description": "The common pieces for Star Network's HTTP-only bots",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"@discordjs/builders": "^1.14.1",
|
|
51
51
|
"@discordjs/collection": "^2.1.1",
|
|
52
52
|
"@sentry/node": "^10.69.0",
|
|
53
|
+
"@wolfstar/plugin-i18next": "^1.0.0",
|
|
53
54
|
"discord-api-types": "^0.38.8",
|
|
54
55
|
"tslib": "^2.8.1",
|
|
55
|
-
"@wolfstar/http-framework-i18n": "^1.2.5",
|
|
56
56
|
"@wolfstar/env-utilities": "^2.0.7",
|
|
57
|
-
"@wolfstar/http-framework": "^3.
|
|
57
|
+
"@wolfstar/http-framework": "^3.2.0-next-20260829215854"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"typescript": "~5.8.3"
|