This repository has been archived on 2025-06-26. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
l1l1th-old/src/commands/fun/userconfig.js
2024-10-11 14:07:01 +02:00

62 lines
No EOL
1.7 KiB
JavaScript

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 })))
},
};