Merge pull request 'removed unused comments, formatted better' (#2) from chore/remove-comments into main
Some checks are pending
Docker Compose Deploy / build_and_deploy (push) Waiting to run
Some checks are pending
Docker Compose Deploy / build_and_deploy (push) Waiting to run
Reviewed-on: https://codeberg.org/RythonDev/portfolio-roast-bot/pulls/2
This commit is contained in:
commit
46c92f5a59
5 changed files with 26 additions and 29 deletions
|
|
@ -6,8 +6,6 @@ use serenity::all::CreateEmbed;
|
||||||
|
|
||||||
// Define your FAQ struct
|
// Define your FAQ struct
|
||||||
struct Faq {
|
struct Faq {
|
||||||
// id: i64,
|
|
||||||
// guild_id: String,
|
|
||||||
title: String,
|
title: String,
|
||||||
description: String,
|
description: String,
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +38,7 @@ async fn autocomplete_faq_titles<'a>(
|
||||||
let guild_id = server_guild_id.to_string();
|
let guild_id = server_guild_id.to_string();
|
||||||
move |conn| {
|
move |conn| {
|
||||||
let mut stmt = conn.prepare(
|
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
|
let faqs: Vec<Faq> = stmt
|
||||||
|
|
@ -64,11 +62,17 @@ async fn autocomplete_faq_titles<'a>(
|
||||||
let partial_lowercase = partial.to_lowercase();
|
let partial_lowercase = partial.to_lowercase();
|
||||||
|
|
||||||
futures::stream::iter(faqs)
|
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)
|
.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> {
|
pub async fn faq(_ctx: Context<'_>) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -162,15 +166,12 @@ pub async fn preview(
|
||||||
let faq = faqs.first().unwrap();
|
let faq = faqs.first().unwrap();
|
||||||
|
|
||||||
// let embed_description = format_embed_description(&faq.description).expect("Format error");
|
// let embed_description = format_embed_description(&faq.description).expect("Format error");
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new().title(&faq.title).description(format!(
|
||||||
.title(&faq.title)
|
"```
|
||||||
.description(
|
|
||||||
format!("```
|
|
||||||
{}
|
{}
|
||||||
```",
|
```",
|
||||||
&faq.description
|
&faq.description
|
||||||
)
|
));
|
||||||
);
|
|
||||||
|
|
||||||
ctx.send(CreateReply::default().embed(embed)).await?;
|
ctx.send(CreateReply::default().embed(embed)).await?;
|
||||||
|
|
||||||
|
|
@ -296,7 +297,12 @@ pub async fn delete(
|
||||||
let result = data
|
let result = data
|
||||||
.execute_db({
|
.execute_db({
|
||||||
let title = title.clone();
|
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?;
|
.await?;
|
||||||
|
|
||||||
|
|
@ -312,4 +318,3 @@ pub async fn delete(
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,6 @@ use poise::CreateReply;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use serenity::all::{CreateEmbed, GuildChannel};
|
use serenity::all::{CreateEmbed, GuildChannel};
|
||||||
|
|
||||||
// struct Forum {
|
|
||||||
// id: i64,
|
|
||||||
// guild_id: String,
|
|
||||||
// forum_id: String,
|
|
||||||
// }
|
|
||||||
|
|
||||||
#[poise::command(slash_command, subcommands("add", "delete"), guild_only)]
|
#[poise::command(slash_command, subcommands("add", "delete"), guild_only)]
|
||||||
pub async fn forum(_ctx: Context<'_>) -> Result<(), Error> {
|
pub async fn forum(_ctx: Context<'_>) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ pub async fn help(
|
||||||
ctx,
|
ctx,
|
||||||
command.as_deref(),
|
command.as_deref(),
|
||||||
poise::builtins::HelpConfiguration {
|
poise::builtins::HelpConfiguration {
|
||||||
// extra_text_at_bottom: "made with ❤️",
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,5 @@ pub fn init_tables(conn: &Connection) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we need to create more tables we'll use this function
|
// if we need to create more tables we'll use this function
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,9 @@ pub async fn on_thread_create(
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let message_builder = CreateMessage::new().content(format!(
|
let message_builder = CreateMessage::new().content(format!(
|
||||||
"<@{}> Please select only ONE (1) tag (personal-only or career-oriented)\n\nYou can edit your post's tags under Post Settings -> Edit Tags",
|
"<@{}> Please select only ONE (1) tag (personal-only or career-oriented)\n\nYou can edit your post's tags under Post Settings -> Edit Tags",
|
||||||
thread_owner
|
thread_owner
|
||||||
));
|
));
|
||||||
|
|
||||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue