mirror of
https://github.com/nx-bat/synapse.git
synced 2026-09-23 10:39:05 -04:00
(database): removing bot settings temporarily, as it isn't being
implemented until majority of the bot has been written. This may require being handled differently. My current considerations are storing as a `.json` or `.ts` file. These options both integrate directly in JavaScript and may be handled in memory, rather than being called through the database. Storing the settings under the '0' identifier is still a valid (and the leading) option.
This commit is contained in:
Vendored
-10
@@ -1,13 +1,3 @@
|
|||||||
// --- Bot Settings ---
|
|
||||||
|
|
||||||
export type Settings = {
|
|
||||||
branding?: BrandingSettings;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type BrandingSettings = {
|
|
||||||
status?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Guild Configuration ---
|
// --- Guild Configuration ---
|
||||||
|
|
||||||
export type Configuration = {
|
export type Configuration = {
|
||||||
|
|||||||
@@ -52,30 +52,6 @@ export async function init(): Promise<void> {
|
|||||||
CREATE INDEX IF NOT EXISTS messages_channel_id_idx
|
CREATE INDEX IF NOT EXISTS messages_channel_id_idx
|
||||||
ON messages (channel_id);
|
ON messages (channel_id);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Ensure global bot settings exist.
|
|
||||||
await client`
|
|
||||||
INSERT INTO settings (id, config)
|
|
||||||
VALUES (0, '{}'::jsonb)
|
|
||||||
ON CONFLICT (id) DO NOTHING;
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getSettings(): Promise<Settings> {
|
|
||||||
const [row] = await client`
|
|
||||||
SELECT config FROM settings
|
|
||||||
WHERE id = '0';
|
|
||||||
`;
|
|
||||||
|
|
||||||
return row.config as Settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function updateSettings(settings: Partial<Settings>): Promise<void> {
|
|
||||||
await client`
|
|
||||||
UPDATE settings
|
|
||||||
SET config = config || ${client.json(settings)}
|
|
||||||
WHERE id = '0';
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Guild Configuration
|
// Guild Configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user