revamp booru

This commit is contained in:
Ashley Graves 2024-10-11 14:07:01 +02:00
parent 7c741f88d5
commit ff2e2ea587
8 changed files with 231 additions and 38 deletions

View file

@ -0,0 +1,62 @@
const { InteractionContextType, ApplicationIntegrationType, SlashCommandBuilder } = require("discord.js");
const { knex } = require("../../db.js");
const configData = {}
const data = new SlashCommandBuilder()
.setName("userconfig")
.setDescription("Manage your user settings")
.setContexts([
InteractionContextType.Guild,
InteractionContextType.BotDM,
InteractionContextType.PrivateChannel
])
.setIntegrationTypes([
ApplicationIntegrationType.UserInstall
]);
for (const option in configData) {
const config = configData[option];
data.addSubcommand((builder) => {
builder
.setName(option)
.setDescription(config.description)
switch (config.type) {
case "bool":
builder.addBooleanOption(builder =>
builder.setName("value")
);
case "channel":
builder.addChannelOption(builder =>
builder.setName("channel")
);
default:
}
})
}
module.exports = {
data,
async execute(interaction) {
interaction.reply("Not implemented yet, sorry!");
},
async autocomplete(interaction) {
const focusedOption = interaction.options.getFocused(true);
const command = interaction.options.getSubcommand(true);
console.log(command, focusedOption);
const id = "";
const choices = [];
for (const option in configData) {
if (focusedOption.name == "name" && option.startsWith(focusedOption.value))
choices.push(option);
else if (focusedOption.name == "value" && (option == interaction.options.getString("name") ?? ""))
choices.push(...buildChoices(option, interaction));
}
await interaction.respond(choices.map(choice => ({ name: choice, value: choice })))
},
};