@getsolara/solara.db
Version:
Optional database functionality for @getsolara/solara.js using quick.db
21 lines • 995 B
JavaScript
module.exports = {
name: "$dbIncrement",
description: "Increments a numeric value in the database. Args: key;[amount=1]",
takesBrackets: true,
execute: async (context, args) => {
if (!context.client.db) {
return "[Error: $dbIncrement requires database features to be enabled. Ensure @getsolara/solara.db is installed and configured correctly.]";
}
if (!args[0]) return "[Error: $dbIncrement requires a key]";
const key = args[0];
const amount = args[1] ? parseFloat(args[1]) : 1;
if (isNaN(amount)) return "[Error: Invalid increment amount for $dbIncrement. Must be a number.]";
try {
await context.client.db.add(key, amount);
return "";
} catch (e) {
console.error(`Solara.db Error ($dbIncrement): Failed to increment key '${key}'. Error: ${e.message}`);
return `[DB Error incrementing key '${key}': ${e.message}]`;
}
}
};