feat(database): add repositories for tickets, moderation, polls and notifications
Keep every SQL statement out of the command layer so each feature can be built and tested without a Discord dependency.
This commit is contained in:
7 files changed
+460
No files matched your search
@@ -7,6 +7,18 @@ export function getSetting(guildId, key, fallback = null) {
|
||||
return row ? JSON.parse(row.value) : fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a setting without throwing when the database is not ready (tests, early startup).
|
||||
* Never use it when a missing database should be an error.
|
||||
*/
|
||||
export function resolveSetting(guildId, key, fallback = null) {
|
||||
try {
|
||||
return getSetting(guildId, key, fallback);
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
export function setSetting(guildId, key, value, updatedBy = null) {
|
||||
getDatabase()
|
||||
.prepare(
|
||||
|
||||
Reference in new issue
Block a user