swapped to a new db locally hosted
This commit is contained in:
@@ -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.`,
|
||||
|
||||
Reference in New Issue
Block a user