2 Commits

Author SHA1 Message Date
Jacob Nguyen
715f373dea fix sern build option 2024-04-11 18:17:28 -05:00
Jacob Nguyen
504331d7ca user install work? 2024-04-10 21:23:48 -05:00
3 changed files with 18 additions and 7 deletions

View File

@@ -144,6 +144,7 @@ const serialize = (permissions: unknown) => {
const makePublishData = ({ commandModule, config }: Record<string, Record<string, unknown>>) => { const makePublishData = ({ commandModule, config }: Record<string, Record<string, unknown>>) => {
const applicationType = intoApplicationType(commandModule.type as number); const applicationType = intoApplicationType(commandModule.type as number);
console.log(config)
return { return {
data: { data: {
name: commandModule.name as string, name: commandModule.name as string,
@@ -153,6 +154,19 @@ const makePublishData = ({ commandModule, config }: Record<string, Record<string
options: optionsTransformer((commandModule?.options ?? []) as Typeable[]), options: optionsTransformer((commandModule?.options ?? []) as Typeable[]),
dm_permission: config?.dmPermission, dm_permission: config?.dmPermission,
default_member_permissions: serialize(config?.defaultMemberPermissions), 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, config,
}; };
@@ -168,8 +182,9 @@ appid && console.warn(`${magentaBright('WARNING')}: APPLICATION_ID is not necess
// partition globally published and guilded commands // partition globally published and guilded commands
const [globalCommands, guildedCommands] = publishableData.reduce( const [globalCommands, guildedCommands] = publishableData.reduce(
([globals, guilded], module) => { ([globals, guilded], module) => {
const isPublishableGlobally = !module.config || !Array.isArray(module.config.guildIds); const isPublishableGlobally = !Array.isArray(module.config?.guildIds);
if (isPublishableGlobally) { if (isPublishableGlobally) {
console.log(module)
return [[module, ...globals], guilded]; return [[module, ...globals], guilded];
} }
return [globals, [module, ...guilded]]; return [globals, [module, ...guilded]];
@@ -186,10 +201,10 @@ const res = await rest.updateGlobal(globalCommands);
let globalCommandsResponse: unknown; let globalCommandsResponse: unknown;
if (res.ok) { if (res.ok) {
globalCommands.length && spin.succeed(`All ${cyanBright('Global')} commands published`); globalCommands.length && spin.succeed(`All ${cyanBright('Global')} commands published`);
globalCommandsResponse = await res.json(); globalCommandsResponse = await res.json();
console.log(globalCommandsResponse)
} else { } else {
spin.fail(`Failed to publish global commands [Code: ${redBright(res.status)}]`); spin.fail(`Failed to publish global commands [Code: ${redBright(res.status)}]`);
let err: Error let err: Error

View File

@@ -39,8 +39,7 @@ program //
.description('New way to manage your slash commands') .description('New way to manage your slash commands')
.option('-W --suppress-warnings', 'suppress experimental warning') .option('-W --suppress-warnings', 'suppress experimental warning')
.option('-i, --import [scriptPath...]', 'Prerequire a script to load into publisher') .option('-i, --import [scriptPath...]', 'Prerequire a script to load into publisher')
.option('-t, --token [token]') .option('-e --env', 'path to .env file')
.option('--appId [applicationId]')
.argument('[path]', 'path with respect to current working directory that will locate all published files') .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))) .action(async (...args) => importDynamic('publish.js').then((m) => m.publish(...args)))
).addCommand( ).addCommand(
@@ -53,7 +52,6 @@ program //
.option('-y, --yes', "Say yes to all prompts") .option('-y, --yes', "Say yes to all prompts")
.option('-e, --env [path]', "Supply a path to a .env") .option('-e, --env [path]', "Supply a path to a .env")
.action(async (...args) => importDynamic('command-clear.js').then((m) => m.commandClear(...args)))); .action(async (...args) => importDynamic('command-clear.js').then((m) => m.commandClear(...args))));
program program
.command('build') .command('build')
.description('Build your bot') .description('Build your bot')

View File

@@ -11,7 +11,6 @@ export async function getConfig(): Promise<sernConfig> {
return output; return output;
} }
export interface sernConfig { export interface sernConfig {
language: 'typescript' | 'javascript'; language: 'typescript' | 'javascript';
defaultPrefix?: string; defaultPrefix?: string;
@@ -20,5 +19,4 @@ export interface sernConfig {
commands: string; commands: string;
events?: string; events?: string;
}; };
buildPath: string;
} }