swapped to a new db locally hosted

This commit is contained in:
2025-10-06 00:25:29 -04:00
parent 097583ca0a
commit ca23c0ab8c
40 changed files with 2244 additions and 556 deletions

View File

@@ -9,13 +9,8 @@ module.exports = {
.setName('setup-autorole')
.setDescription('Interactively set up the autorole for this server.'),
async execute(interaction) {
const db = readDb();
const guildId = interaction.guildId;
if (!db[guildId]) {
db[guildId] = {};
}
const roleSelect = new RoleSelectMenuBuilder()
.setCustomId('autorole_role_select')
.setPlaceholder('Select the role to assign on join.');
@@ -45,11 +40,20 @@ module.exports = {
return;
}
db[guildId].autorole = {
enabled: true,
roleId: roleId,
};
writeDb(db);
// persist to backend
try {
const api = require('../api');
const existing = await api.getServerSettings(guildId) || {};
existing.autorole = { enabled: true, roleId };
await api.upsertServerSettings(guildId, existing);
} catch (e) {
console.error('Error persisting autorole to backend, falling back to local:', e);
const { readDb, writeDb } = require('../../backend/db.js');
const db = readDb();
if (!db[guildId]) db[guildId] = {};
db[guildId].autorole = { enabled: true, roleId };
writeDb(db);
}
await roleConfirmation.update({
content: `Autorole setup complete! New members will be assigned the **${role.name}** role.`,