mirror of
https://github.com/sern-handler/cli
synced 2026-06-06 01:16:53 +00:00
fix config fn defai;lt
This commit is contained in:
@@ -79,12 +79,6 @@ for await (const absPath of filePaths) {
|
|||||||
commandModule = commandModule.default;
|
commandModule = commandModule.default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
commandModule = commandModule.getInstance();
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
if ((PUBLISHABLE & commandModule.type) != 0) {
|
if ((PUBLISHABLE & commandModule.type) != 0) {
|
||||||
// assign defaults
|
// assign defaults
|
||||||
const filename = basename(absPath);
|
const filename = basename(absPath);
|
||||||
@@ -92,11 +86,11 @@ for await (const absPath of filePaths) {
|
|||||||
commandModule.name ??= filenameNoExtension;
|
commandModule.name ??= filenameNoExtension;
|
||||||
commandModule.description ??= '';
|
commandModule.description ??= '';
|
||||||
commandModule.absPath = absPath;
|
commandModule.absPath = absPath;
|
||||||
|
if (typeof config === 'function') {
|
||||||
|
config = config(absPath, commandModule);
|
||||||
|
}
|
||||||
modules.push({ commandModule, config });
|
modules.push({ commandModule, config });
|
||||||
}
|
}
|
||||||
if (typeof config === 'function') {
|
|
||||||
config = config(absPath, commandModule);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const cacheDir = resolve('./.sern');
|
const cacheDir = resolve('./.sern');
|
||||||
@@ -158,9 +152,9 @@ const makePublishData = ({ commandModule, config }: Record<string, Record<string
|
|||||||
integration_types: (config?.integrationTypes ?? ['Guild']).map(
|
integration_types: (config?.integrationTypes ?? ['Guild']).map(
|
||||||
(s: string) => {
|
(s: string) => {
|
||||||
if(s === "Guild") {
|
if(s === "Guild") {
|
||||||
return 0
|
return "0"
|
||||||
} else if (s == "User") {
|
} else if (s == "User") {
|
||||||
return 1
|
return "1"
|
||||||
} else {
|
} else {
|
||||||
throw Error("IntegrationType is not one of Guild or User");
|
throw Error("IntegrationType is not one of Guild or User");
|
||||||
}
|
}
|
||||||
@@ -287,7 +281,6 @@ const remoteData = {
|
|||||||
global: globalCommandsResponse,
|
global: globalCommandsResponse,
|
||||||
...Object.fromEntries(guildCommandMapResponse),
|
...Object.fromEntries(guildCommandMapResponse),
|
||||||
};
|
};
|
||||||
|
|
||||||
await writeFile(resolve(cacheDir, 'command-data-remote.json'), JSON.stringify(remoteData, null, 4), 'utf8');
|
await writeFile(resolve(cacheDir, 'command-data-remote.json'), JSON.stringify(remoteData, null, 4), 'utf8');
|
||||||
|
|
||||||
// TODO: add this in a verbose flag
|
// TODO: add this in a verbose flag
|
||||||
|
|||||||
10
src/rest.ts
10
src/rest.ts
@@ -4,12 +4,12 @@ const baseURL = new URL('https://discord.com/api/v10/applications/');
|
|||||||
|
|
||||||
const excludedKeys = new Set(['command', 'absPath']);
|
const excludedKeys = new Set(['command', 'absPath']);
|
||||||
|
|
||||||
const publishablesIntoJson = (ps: PublishableModule[]) =>
|
const publishablesIntoJson = (ps: PublishableModule[]) => {
|
||||||
JSON.stringify(
|
const s = JSON.stringify(
|
||||||
ps.map((module) => module.data),
|
ps.map((module) => module.data),
|
||||||
(key, value) => (excludedKeys.has(key) ? undefined : value),
|
(key, value) => (excludedKeys.has(key) ? undefined : value), 4);
|
||||||
4
|
return s;
|
||||||
);
|
}
|
||||||
|
|
||||||
export const create = async (token: string) => {
|
export const create = async (token: string) => {
|
||||||
const headers = {
|
const headers = {
|
||||||
|
|||||||
Reference in New Issue
Block a user