joel image handler
This commit is contained in:
@@ -245,6 +245,7 @@ export function createApiRoutes(client: BotClient) {
|
||||
memory_chance: 30,
|
||||
mention_probability: 0,
|
||||
gif_search_enabled: 0,
|
||||
image_gen_enabled: 0,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -268,6 +269,7 @@ export function createApiRoutes(client: BotClient) {
|
||||
memory_chance?: number;
|
||||
mention_probability?: number;
|
||||
gif_search_enabled?: boolean | string;
|
||||
image_gen_enabled?: boolean | string;
|
||||
};
|
||||
|
||||
if (contentType?.includes("application/x-www-form-urlencoded")) {
|
||||
@@ -278,13 +280,15 @@ export function createApiRoutes(client: BotClient) {
|
||||
memory_chance: form.memory_chance ? parseInt(form.memory_chance as string) : undefined,
|
||||
mention_probability: form.mention_probability ? parseInt(form.mention_probability as string) : undefined,
|
||||
gif_search_enabled: form.gif_search_enabled === "on" || form.gif_search_enabled === "true",
|
||||
image_gen_enabled: form.image_gen_enabled === "on" || form.image_gen_enabled === "true",
|
||||
};
|
||||
} else {
|
||||
body = await c.req.json();
|
||||
}
|
||||
|
||||
// Convert gif_search_enabled to integer for SQLite
|
||||
// Convert boolean options to integer for SQLite
|
||||
const gifSearchEnabled = body.gif_search_enabled ? 1 : 0;
|
||||
const imageGenEnabled = body.image_gen_enabled ? 1 : 0;
|
||||
|
||||
// Upsert options
|
||||
const existing = await db
|
||||
@@ -301,6 +305,7 @@ export function createApiRoutes(client: BotClient) {
|
||||
memory_chance: body.memory_chance,
|
||||
mention_probability: body.mention_probability,
|
||||
gif_search_enabled: gifSearchEnabled,
|
||||
image_gen_enabled: imageGenEnabled,
|
||||
});
|
||||
} else {
|
||||
await db
|
||||
@@ -311,6 +316,7 @@ export function createApiRoutes(client: BotClient) {
|
||||
memory_chance: body.memory_chance,
|
||||
mention_probability: body.mention_probability,
|
||||
gif_search_enabled: gifSearchEnabled,
|
||||
image_gen_enabled: imageGenEnabled,
|
||||
updated_at: new Date().toISOString(),
|
||||
})
|
||||
.where(eq(botOptions.guild_id, guildId));
|
||||
|
||||
Reference in New Issue
Block a user