UNPKG

@getsolara/solara.db

Version:

Optional database functionality for @getsolara/solara.js using quick.db

22 lines 1.16 kB
module.exports = { name: "$getServerVar", description: "Gets a variable associated with the current guild. Args: varName", takesBrackets: true, execute: async (context, args) => { if (!context.client.db) { return "[Error: $getServerVar requires database features to be enabled. Ensure @getsolara/solara.db is installed and configured correctly.]"; } if (!args[0]) return "[Error: $getServerVar requires a varName]"; const varName = args[0].trim(); if (!context.guild) return "[Error: $getServerVar requires a guild context]"; if (!varName) return "[Error: Variable name cannot be empty for $getServerVar]"; const dbKey = `serverVars_${context.guild.id}_${varName}`; try { const value = await context.client.db.get(dbKey); return value !== null && value !== undefined ? String(value) : ""; } catch (e) { console.error(`Solara.db Error ($getServerVar): Failed to get key '${dbKey}'. Error: ${e.message}`); return `[DB Error getting server variable '${varName}': ${e.message}]`; } } };