chore: improve dev experience via docker override, and remove redundant commands.
All checks were successful
Deploy to Production / test (push) Successful in 43s
All checks were successful
Deploy to Production / test (push) Successful in 43s
This commit is contained in:
@@ -1,68 +0,0 @@
|
|||||||
import { createCommand } from "@shared/lib/utils";
|
|
||||||
import { SlashCommandBuilder, PermissionFlagsBits, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalSubmitInteraction } from "discord.js";
|
|
||||||
import { config, saveConfig } from "@shared/lib/config";
|
|
||||||
import type { GameConfigType } from "@shared/lib/config";
|
|
||||||
import { createSuccessEmbed, createErrorEmbed } from "@lib/embeds";
|
|
||||||
|
|
||||||
export const configCommand = createCommand({
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName("config")
|
|
||||||
.setDescription("Edit the bot configuration")
|
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
|
||||||
execute: async (interaction) => {
|
|
||||||
console.log(`Config command executed by ${interaction.user.tag}`);
|
|
||||||
const replacer = (key: string, value: any) => {
|
|
||||||
if (typeof value === 'bigint') {
|
|
||||||
return value.toString();
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
const currentConfigJson = JSON.stringify(config, replacer, 4);
|
|
||||||
|
|
||||||
const modal = new ModalBuilder()
|
|
||||||
.setCustomId("config-modal")
|
|
||||||
.setTitle("Edit Configuration");
|
|
||||||
|
|
||||||
const jsonInput = new TextInputBuilder()
|
|
||||||
.setCustomId("json-input")
|
|
||||||
.setLabel("Configuration JSON")
|
|
||||||
.setStyle(TextInputStyle.Paragraph)
|
|
||||||
.setValue(currentConfigJson)
|
|
||||||
.setRequired(true);
|
|
||||||
|
|
||||||
const actionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(jsonInput);
|
|
||||||
modal.addComponents(actionRow);
|
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const submitted = await interaction.awaitModalSubmit({
|
|
||||||
time: 300000, // 5 minutes
|
|
||||||
filter: (i) => i.customId === "config-modal" && i.user.id === interaction.user.id
|
|
||||||
});
|
|
||||||
|
|
||||||
const jsonString = submitted.fields.getTextInputValue("json-input");
|
|
||||||
|
|
||||||
try {
|
|
||||||
const newConfig = JSON.parse(jsonString);
|
|
||||||
saveConfig(newConfig as GameConfigType);
|
|
||||||
|
|
||||||
await submitted.reply({
|
|
||||||
embeds: [createSuccessEmbed("Configuration updated successfully.", "Config Saved")]
|
|
||||||
});
|
|
||||||
} catch (parseError) {
|
|
||||||
await submitted.reply({
|
|
||||||
embeds: [createErrorEmbed(`Invalid JSON: ${parseError instanceof Error ? parseError.message : String(parseError)}`, "Config Update Failed")],
|
|
||||||
ephemeral: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
// Timeout or other error handling if needed, usually just ignore timeouts for modals
|
|
||||||
if (error instanceof Error && error.message.includes('time')) {
|
|
||||||
// specific timeout handling if desired
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
import { createCommand } from "@shared/lib/utils";
|
|
||||||
import { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } from "discord.js";
|
|
||||||
import { createBaseEmbed } from "@lib/embeds";
|
|
||||||
import { config, reloadConfig, toggleCommand } from "@shared/lib/config";
|
|
||||||
import { AuroraClient } from "@/lib/BotClient";
|
|
||||||
|
|
||||||
export const features = createCommand({
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName("features")
|
|
||||||
.setDescription("Manage bot features and commands")
|
|
||||||
.addSubcommand(sub =>
|
|
||||||
sub.setName("list")
|
|
||||||
.setDescription("List all commands and their status")
|
|
||||||
)
|
|
||||||
.addSubcommand(sub =>
|
|
||||||
sub.setName("toggle")
|
|
||||||
.setDescription("Enable or disable a command")
|
|
||||||
.addStringOption(option =>
|
|
||||||
option.setName("command")
|
|
||||||
.setDescription("The name of the command")
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
.addBooleanOption(option =>
|
|
||||||
option.setName("enabled")
|
|
||||||
.setDescription("Whether the command should be enabled")
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
|
||||||
execute: async (interaction) => {
|
|
||||||
const subcommand = interaction.options.getSubcommand();
|
|
||||||
|
|
||||||
if (subcommand === "list") {
|
|
||||||
const activeCommands = AuroraClient.commands;
|
|
||||||
const categories = new Map<string, string[]>();
|
|
||||||
|
|
||||||
// Group active commands
|
|
||||||
activeCommands.forEach(cmd => {
|
|
||||||
const cat = cmd.category || 'Uncategorized';
|
|
||||||
if (!categories.has(cat)) categories.set(cat, []);
|
|
||||||
categories.get(cat)!.push(cmd.data.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Config overrides
|
|
||||||
const overrides = Object.entries(config.commands)
|
|
||||||
.map(([name, enabled]) => `• **${name}**: ${enabled ? "✅ Enabled (Override)" : "❌ Disabled"}`);
|
|
||||||
|
|
||||||
const embed = createBaseEmbed("Command Features", undefined, "Blue");
|
|
||||||
|
|
||||||
// Add fields for each category
|
|
||||||
const sortedCategories = [...categories.keys()].sort();
|
|
||||||
for (const cat of sortedCategories) {
|
|
||||||
const cmds = categories.get(cat)!.sort();
|
|
||||||
const cmdList = cmds.map(name => {
|
|
||||||
const isOverride = config.commands[name] !== undefined;
|
|
||||||
return isOverride ? `**${name}** (See Overrides)` : `**${name}**`;
|
|
||||||
}).join(", ");
|
|
||||||
|
|
||||||
embed.addFields({ name: `📂 ${cat.toUpperCase()}`, value: cmdList || "None" });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (overrides.length > 0) {
|
|
||||||
embed.addFields({ name: "⚙️ Configuration Overrides", value: overrides.join("\n") });
|
|
||||||
} else {
|
|
||||||
embed.addFields({ name: "⚙️ Configuration Overrides", value: "No overrides set." });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check permissions manually as a fallback (though defaultMemberPermissions handles it at the API level)
|
|
||||||
if (!interaction.memberPermissions?.has(PermissionFlagsBits.Administrator)) {
|
|
||||||
await interaction.reply({ content: "❌ You need Administrator permissions to use this command.", flags: MessageFlags.Ephemeral });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral });
|
|
||||||
} else if (subcommand === "toggle") {
|
|
||||||
const commandName = interaction.options.getString("command", true);
|
|
||||||
const enabled = interaction.options.getBoolean("enabled", true);
|
|
||||||
|
|
||||||
await interaction.deferReply({ flags: MessageFlags.Ephemeral });
|
|
||||||
|
|
||||||
toggleCommand(commandName, enabled);
|
|
||||||
|
|
||||||
await interaction.editReply({ content: `✅ Command **${commandName}** has been ${enabled ? "enabled" : "disabled"}. Reloading configuration...` });
|
|
||||||
|
|
||||||
// Reload config from disk (which was updated by toggleCommand)
|
|
||||||
reloadConfig();
|
|
||||||
|
|
||||||
await AuroraClient.loadCommands(true);
|
|
||||||
await AuroraClient.deployCommands();
|
|
||||||
|
|
||||||
await interaction.editReply({ content: `✅ Command **${commandName}** has been ${enabled ? "enabled" : "disabled"}. Commands reloaded!` });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
10
docker-compose.override.yml.linux
Normal file
10
docker-compose.override.yml.linux
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
services:
|
||||||
|
db:
|
||||||
|
volumes:
|
||||||
|
# Override the bind mount with a named volume
|
||||||
|
# Docker handles permissions automatically for named volumes
|
||||||
|
- db_data:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db_data:
|
||||||
|
name: aurora_db_data
|
||||||
Reference in New Issue
Block a user