minor bug fix

This commit is contained in:
Stachelbeere1248 2024-11-15 23:48:34 +01:00
parent f86eefe7c4
commit 96d0377665
Signed by: Stachelbeere1248
SSH key fingerprint: SHA256:IozEKdw2dB8TZxkpPdMxcWSoWTIMwoLaCcZJ1AJnY2o
2 changed files with 12 additions and 11 deletions

View file

@ -131,7 +131,7 @@ impl Link {
Ok(self) Ok(self)
} }
} }
#[poise::command(slash_command, subcommands("add", "list", "context_list"))] #[poise::command(slash_command, subcommands("add", "list"))]
pub(crate) async fn account(_ctx: Context<'_>) -> Result<(), Error> { pub(crate) async fn account(_ctx: Context<'_>) -> Result<(), Error> {
// root of slash-commands is not invokable. // root of slash-commands is not invokable.
unreachable!() unreachable!()
@ -252,18 +252,18 @@ pub(crate) async fn list(ctx: Context<'_>, user: Option<User>) -> Result<(), Err
Ok(()) Ok(())
} }
#[poise::command(context_menu_command="list accounts")] #[poise::command(context_menu_command="Account list")]
pub(crate) async fn context_list(ctx: Context<'_>, m: Message) -> Result<(), Error> { pub(crate) async fn context_list(ctx: Context<'_>, m: Message) -> Result<(), Error> {
ctx.defer_ephemeral().await?; ctx.defer_ephemeral().await?;
cooldown(&ctx, 600, 300)?; cooldown(&ctx, 600, 300)?;
let pool: &Pool<Sqlite> = &ctx.data().sqlite_pool; let pool: &Pool<Sqlite> = &ctx.data().sqlite_pool;
let s: String = list_string(pool, &m.author).await?; let s: String = list_string(pool, &m.author).await?;
let r: CreateReply = CreateReply::default().ephemeral(true);
ctx.send( ctx.send(
r.content(s) CreateReply::default()
.allowed_mentions(CreateAllowedMentions::new().empty_roles().empty_users()), .content(s)
) .allowed_mentions(CreateAllowedMentions::new().empty_roles().empty_users())
.await?; .ephemeral(true)
).await?;
Ok(()) Ok(())
} }

View file

@ -48,6 +48,7 @@ async fn main() {
commands::helpstart::helpstart(), commands::helpstart::helpstart(),
commands::bots::bots(), commands::bots::bots(),
commands::accountv2::account(), commands::accountv2::account(),
commands::accountv2::context_list(),
], ],
manual_cooldowns: true, manual_cooldowns: true,
prefix_options: poise::PrefixFrameworkOptions { prefix_options: poise::PrefixFrameworkOptions {
@ -96,7 +97,7 @@ async fn event_handler(
match event { match event {
FullEvent::Ready { data_about_bot, .. } => { FullEvent::Ready { data_about_bot, .. } => {
println!("Logged in as {}", data_about_bot.user.name); println!("Logged in as {}", data_about_bot.user.name);
} },
FullEvent::GuildMemberAddition { new_member } => { FullEvent::GuildMemberAddition { new_member } => {
println!("join event"); println!("join event");
if new_member.guild_id.get() == 1256217633959841853_u64 { if new_member.guild_id.get() == 1256217633959841853_u64 {
@ -108,13 +109,13 @@ async fn event_handler(
if interaction.application_id().get() == 1165594074473037824 && interaction.kind() == InteractionType::Component { if interaction.application_id().get() == 1165594074473037824 && interaction.kind() == InteractionType::Component {
handlers::bot_interaction::component(ctx, interaction, data).await?; handlers::bot_interaction::component(ctx, interaction, data).await?;
} }
} },
FullEvent::Message { new_message } => { FullEvent::Message { new_message } => {
handlers::message::on_create(ctx, new_message).await?; handlers::message::on_create(ctx, new_message).await?;
} },
FullEvent::ThreadCreate { thread } => { FullEvent::ThreadCreate { thread } => {
handlers::thread::on_create(ctx, thread).await?; handlers::thread::on_create(ctx, thread).await?;
} },
_ => {} _ => {}
} }
Ok(()) Ok(())