Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoobes authored May 27, 2024
2 parents 69a0acd + fe2e8ff commit 7172afe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
17 changes: 5 additions & 12 deletions src/create-publish.mts
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,18 @@ for await (const absPath of filePaths) {
commandModule = commandModule.default;
}



try {
commandModule = commandModule.getInstance();
} catch {}

if ((PUBLISHABLE & commandModule.type) != 0) {
// assign defaults
const filename = basename(absPath);
const filenameNoExtension = filename.substring(0, filename.lastIndexOf('.'));
commandModule.name ??= filenameNoExtension;
commandModule.description ??= '';
commandModule.absPath = absPath;
if (typeof config === 'function') {
config = config(absPath, commandModule);
}
modules.push({ commandModule, config });
}
if (typeof config === 'function') {
config = config(absPath, commandModule);
}
}

const cacheDir = resolve('./.sern');
Expand Down Expand Up @@ -158,9 +152,9 @@ const makePublishData = ({ commandModule, config }: Record<string, Record<string
integration_types: (config?.integrationTypes ?? ['Guild']).map(
(s: string) => {
if(s === "Guild") {
return 0
return "0"
} else if (s == "User") {
return 1
return "1"
} else {
throw Error("IntegrationType is not one of Guild or User");
}
Expand Down Expand Up @@ -287,7 +281,6 @@ const remoteData = {
global: globalCommandsResponse,
...Object.fromEntries(guildCommandMapResponse),
};

await writeFile(resolve(cacheDir, 'command-data-remote.json'), JSON.stringify(remoteData, null, 4), 'utf8');

// TODO: add this in a verbose flag
Expand Down
10 changes: 5 additions & 5 deletions src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const baseURL = new URL('https://discord.com/api/v10/applications/');

const excludedKeys = new Set(['command', 'absPath']);

const publishablesIntoJson = (ps: PublishableModule[]) =>
JSON.stringify(
const publishablesIntoJson = (ps: PublishableModule[]) => {
const s = JSON.stringify(
ps.map((module) => module.data),
(key, value) => (excludedKeys.has(key) ? undefined : value),
4
);
(key, value) => (excludedKeys.has(key) ? undefined : value), 4);
return s;
}

export const create = async (token: string) => {
const headers = {
Expand Down

0 comments on commit 7172afe

Please sign in to comment.