Compare commits

..

No commits in common. "46c92f5a5954e205ef24b19c51db427c4748e226" and "c6cb16cf6a9e6d2277fc0e2fb91acca8ea62ee0d" have entirely different histories.

5 changed files with 29 additions and 26 deletions

View file

@ -6,6 +6,8 @@ use serenity::all::CreateEmbed;
// Define your FAQ struct
struct Faq {
// id: i64,
// guild_id: String,
title: String,
description: String,
}
@ -38,7 +40,7 @@ async fn autocomplete_faq_titles<'a>(
let guild_id = server_guild_id.to_string();
move |conn| {
let mut stmt = conn.prepare(
"SELECT id, guild_id, title, description FROM faqs WHERE guild_id = ?1",
"SELECT id, guild_id, title, description FROM faqs WHERE guild_id = ?1"
)?;
let faqs: Vec<Faq> = stmt
@ -62,17 +64,11 @@ async fn autocomplete_faq_titles<'a>(
let partial_lowercase = partial.to_lowercase();
futures::stream::iter(faqs)
.filter(move |faq| {
futures::future::ready(faq.title.to_lowercase().contains(&partial_lowercase))
})
.filter(move |faq| futures::future::ready(faq.title.to_lowercase().contains(&partial_lowercase)))
.map(|faq| faq.title)
}
#[poise::command(
slash_command,
subcommands("view", "preview", "add", "edit", "delete"),
guild_only
)]
#[poise::command(slash_command, subcommands("view", "preview", "add", "edit", "delete"), guild_only)]
pub async fn faq(_ctx: Context<'_>) -> Result<(), Error> {
Ok(())
}
@ -166,12 +162,15 @@ pub async fn preview(
let faq = faqs.first().unwrap();
// let embed_description = format_embed_description(&faq.description).expect("Format error");
let embed = CreateEmbed::new().title(&faq.title).description(format!(
"```
let embed = CreateEmbed::new()
.title(&faq.title)
.description(
format!("```
{}
```",
&faq.description
));
)
);
ctx.send(CreateReply::default().embed(embed)).await?;
@ -297,12 +296,7 @@ pub async fn delete(
let result = data
.execute_db({
let title = title.clone();
move |conn| {
conn.execute(
"DELETE FROM faqs WHERE title = ?1 AND guild_id = ?2",
[title, guild_id],
)
}
move |conn| conn.execute("DELETE FROM faqs WHERE title = ?1 AND guild_id = ?2", [title, guild_id])
})
.await?;
@ -318,3 +312,4 @@ pub async fn delete(
Ok(())
}

View file

@ -3,6 +3,12 @@ use poise::CreateReply;
use rusqlite::Connection;
use serenity::all::{CreateEmbed, GuildChannel};
// struct Forum {
// id: i64,
// guild_id: String,
// forum_id: String,
// }
#[poise::command(slash_command, subcommands("add", "delete"), guild_only)]
pub async fn forum(_ctx: Context<'_>) -> Result<(), Error> {
Ok(())

View file

@ -12,6 +12,7 @@ pub async fn help(
ctx,
command.as_deref(),
poise::builtins::HelpConfiguration {
// extra_text_at_bottom: "made with ❤️",
..Default::default()
},
)

View file

@ -63,5 +63,6 @@ pub fn init_tables(conn: &Connection) -> Result<()> {
}
// if we need to create more tables we'll use this function
Ok(())
}