qotd
This commit is contained in:
parent
0514afd32f
commit
e0d50f68bc
6 changed files with 461 additions and 412 deletions
837
Cargo.lock
generated
837
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,7 @@ env_logger = "0.11.3"
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
regex = "1.10.4"
|
regex = "1.10.4"
|
||||||
sqlx = { version = "0.7.4" , features = ["sqlite", "sqlx-sqlite", "runtime-tokio"]}
|
sqlx = { version = "0.8.2", features = ["sqlite", "sqlx-sqlite", "runtime-tokio"]}
|
||||||
reqwest = { version = "0.12.5" }
|
reqwest = { version = "0.12.5" }
|
||||||
serde = { version = "1.0.203", features = ["derive"] }
|
serde = { version = "1.0.203", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.119" }
|
serde_json = { version = "1.0.119" }
|
|
@ -1,7 +1,7 @@
|
||||||
use serenity::all::{ComponentInteraction, ComponentInteractionDataKind, Context, CreateMessage, EditMessage, GuildId, Interaction, RoleId};
|
use serenity::all::{ComponentInteraction, ComponentInteractionDataKind, Context, CreateMessage, EditMessage, GuildId, Interaction, RoleId};
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
pub(crate) async fn component(ctx: &Context, interaction: &Interaction) -> Result<(), Error>{
|
pub(crate) async fn component(ctx: &Context, interaction: &Interaction) -> Result<(), Error> {
|
||||||
let component = interaction.clone().message_component().unwrap();
|
let component = interaction.clone().message_component().unwrap();
|
||||||
match component.data.kind {
|
match component.data.kind {
|
||||||
ComponentInteractionDataKind::Button => button(ctx, component, ).await,
|
ComponentInteractionDataKind::Button => button(ctx, component, ).await,
|
||||||
|
@ -9,7 +9,7 @@ pub(crate) async fn component(ctx: &Context, interaction: &Interaction) -> Resul
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn button(ctx: &Context, mut component: ComponentInteraction) -> Result<(), Error>{
|
async fn button(ctx: &Context, mut component: ComponentInteraction) -> Result<(), Error> {
|
||||||
let m = component.message.clone();
|
let m = component.message.clone();
|
||||||
let u = m.mentions.first().expect("Message did not mention a user.");
|
let u = m.mentions.first().expect("Message did not mention a user.");
|
||||||
match component.data.custom_id.as_str() {
|
match component.data.custom_id.as_str() {
|
||||||
|
|
24
src/handlers/message.rs
Normal file
24
src/handlers/message.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
use serenity::all::{Context, Message};
|
||||||
|
use crate::Error;
|
||||||
|
|
||||||
|
pub(crate) async fn create(ctx: &Context, msg: &Message) -> Result<(), Error> {
|
||||||
|
match msg.guild_id.map(|g| g.get()) {
|
||||||
|
None => Ok(()),
|
||||||
|
Some(1256217633959841853_u64) => {
|
||||||
|
zmp_create(ctx, msg).await
|
||||||
|
},
|
||||||
|
_ => Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn zmp_create(ctx: &Context, msg: &Message) -> Result<(), Error> {
|
||||||
|
match msg.channel_id.get() {
|
||||||
|
1295108216388325386_u64 => {
|
||||||
|
msg.react(ctx, '🇼').await?;
|
||||||
|
msg.react(ctx, '🇱').await?;
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
_ => Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
pub(crate) mod bot_interaction;
|
pub(crate) mod bot_interaction;
|
||||||
|
pub(crate) mod message;
|
|
@ -116,6 +116,9 @@ async fn event_handler(
|
||||||
&& interaction.kind() == InteractionType::Component {
|
&& interaction.kind() == InteractionType::Component {
|
||||||
handlers::bot_interaction::component(ctx, interaction).await?;
|
handlers::bot_interaction::component(ctx, interaction).await?;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
FullEvent::Message { new_message } => {
|
||||||
|
handlers::message::create(ctx, new_message).await?;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue