Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build options #136

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/create-publish.mts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const serialize = (permissions: unknown) => {

const makePublishData = ({ commandModule, config }: Record<string, Record<string, unknown>>) => {
const applicationType = intoApplicationType(commandModule.type as number);
console.log(config)
return {
data: {
name: commandModule.name as string,
Expand All @@ -153,6 +154,19 @@ const makePublishData = ({ commandModule, config }: Record<string, Record<string
options: optionsTransformer((commandModule?.options ?? []) as Typeable[]),
dm_permission: config?.dmPermission,
default_member_permissions: serialize(config?.defaultMemberPermissions),
//@ts-ignore
integration_types: (config?.integrationTypes ?? ['Guild']).map(
(s: string) => {
if(s === "Guild") {
return 0
} else if (s == "User") {
return 1
} else {
throw Error("IntegrationType is not one of Guild or User");
}
}),
//@ts-ignore
contexts: config?.contexts ? config.contexts : undefined
},
config,
};
Expand All @@ -168,8 +182,9 @@ appid && console.warn(`${magentaBright('WARNING')}: APPLICATION_ID is not necess
// partition globally published and guilded commands
const [globalCommands, guildedCommands] = publishableData.reduce(
([globals, guilded], module) => {
const isPublishableGlobally = !module.config || !Array.isArray(module.config.guildIds);
const isPublishableGlobally = !Array.isArray(module.config?.guildIds);
if (isPublishableGlobally) {
console.log(module)
return [[module, ...globals], guilded];
}
return [globals, [module, ...guilded]];
Expand All @@ -186,10 +201,10 @@ const res = await rest.updateGlobal(globalCommands);

let globalCommandsResponse: unknown;


if (res.ok) {
globalCommands.length && spin.succeed(`All ${cyanBright('Global')} commands published`);
globalCommandsResponse = await res.json();
console.log(globalCommandsResponse)
} else {
spin.fail(`Failed to publish global commands [Code: ${redBright(res.status)}]`);
let err: Error
Expand Down
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ program //
.description('New way to manage your slash commands')
.option('-W --suppress-warnings', 'suppress experimental warning')
.option('-i, --import [scriptPath...]', 'Prerequire a script to load into publisher')
.option('-t, --token [token]')
.option('--appId [applicationId]')
.option('-e --env', 'path to .env file')
.argument('[path]', 'path with respect to current working directory that will locate all published files')
.action(async (...args) => importDynamic('publish.js').then((m) => m.publish(...args)))
).addCommand(
Expand All @@ -53,7 +52,6 @@ program //
.option('-y, --yes', "Say yes to all prompts")
.option('-e, --env [path]', "Supply a path to a .env")
.action(async (...args) => importDynamic('command-clear.js').then((m) => m.commandClear(...args))));

program
.command('build')
.description('Build your bot')
Expand Down
2 changes: 0 additions & 2 deletions src/utilities/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export async function getConfig(): Promise<sernConfig> {

return output;
}

export interface sernConfig {
language: 'typescript' | 'javascript';
defaultPrefix?: string;
Expand All @@ -20,5 +19,4 @@ export interface sernConfig {
commands: string;
events?: string;
};
buildPath: string;
}
Loading