mirror of
https://github.com/sern-handler/cli
synced 2026-06-06 01:16:53 +00:00
more progress
This commit is contained in:
@@ -170,11 +170,11 @@ export async function build(options: Record<string, any>) {
|
||||
}
|
||||
const importedModulesTemplate = template
|
||||
.replace("\"use modules\";", commandsImports.join("\n"))
|
||||
.replace("\"use handle\";", `
|
||||
.replace("\"use slash\";", `
|
||||
${commandsPaths.map((imp, i) => {
|
||||
if(i === 0) {
|
||||
return `if(interaction.data.name === "${p.parse(imp).name}") {
|
||||
const data = createContext(interaction)
|
||||
const data = createContext(interaction);
|
||||
const success = await applyPlugins(${p.parse(imp).name}, data);
|
||||
if(success) {
|
||||
await ${p.parse(imp).name}.execute(data);
|
||||
@@ -182,13 +182,14 @@ export async function build(options: Record<string, any>) {
|
||||
}`
|
||||
}
|
||||
return `else if(interaction.data.name === "${p.parse(imp).name}" ) {
|
||||
const data = createContext(interaction)
|
||||
const data = createContext(interaction);
|
||||
const success = await applyPlugins(${p.parse(imp).name}, data);
|
||||
if(success) {
|
||||
await ${p.parse(imp).name}.execute(data);
|
||||
}
|
||||
}`
|
||||
}).join("\n")}`.trim());
|
||||
}).join("\n")}`.trim())
|
||||
|
||||
|
||||
await writeFile("./dist/out.js", importedModulesTemplate);
|
||||
} else {
|
||||
|
||||
@@ -80,34 +80,10 @@ router.post('/', async (request, env) => {
|
||||
type: InteractionResponseType.PONG,
|
||||
});
|
||||
}
|
||||
|
||||
if (interaction.type === InteractionType.APPLICATION_COMMAND) {
|
||||
"use handle";
|
||||
// Most user commands will come as `APPLICATION_COMMAND`.
|
||||
// switch (interaction.data.name.toLowerCase()) {
|
||||
// case AWW_COMMAND.name.toLowerCase(): {
|
||||
// const cuteUrl = await getCuteUrl();
|
||||
// return new JsonResponse({
|
||||
// type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
// data: {
|
||||
// content: cuteUrl,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// case INVITE_COMMAND.name.toLowerCase(): {
|
||||
// const applicationId = env.DISCORD_APPLICATION_ID;
|
||||
// const INVITE_URL = `https://discord.com/oauth2/authorize?client_id=${applicationId}&scope=applications.commands`;
|
||||
// return new JsonResponse({
|
||||
// type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
// data: {
|
||||
// content: INVITE_URL,
|
||||
// flags: InteractionResponseFlags.EPHEMERAL,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// default:
|
||||
// return new JsonResponse({ error: 'Unknown Type' }, { status: 400 });
|
||||
// }
|
||||
if(interaction.type === InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE) {
|
||||
"use autocomplete";
|
||||
} else if (interaction.type === InteractionType.APPLICATION_COMMAND) {
|
||||
"use slash";
|
||||
}
|
||||
|
||||
console.error('Unknown Type');
|
||||
|
||||
Reference in New Issue
Block a user