guh
This commit is contained in:
@@ -67,7 +67,7 @@ impl Retrive {
|
|||||||
|
|
||||||
let mut summary_string: String = String::new();
|
let mut summary_string: String = String::new();
|
||||||
for x in map {
|
for x in map {
|
||||||
summary_string.push_str(format!("#{} | {} \n", x.0, x.1).as_str());
|
summary_string.push_str(format!("- <#{}> | {} Messages \n", x.0, x.1).as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
let embed = CreateEmbed::new()
|
let embed = CreateEmbed::new()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use entities::{channel, content, members, messages, server};
|
use entities::{channel, content, members, messages, server};
|
||||||
|
use migration::prelude::{DateTime, Utc};
|
||||||
use sea_orm::{ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter};
|
use sea_orm::{ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter};
|
||||||
use serenity::all::{Context, Message};
|
use serenity::all::{Context, Message};
|
||||||
|
|
||||||
@@ -34,11 +35,16 @@ pub async fn log_message(
|
|||||||
let channel_id = msg.channel(&ctx.http).await.unwrap().id().get() as i64;
|
let channel_id = msg.channel(&ctx.http).await.unwrap().id().get() as i64;
|
||||||
let channel = channel::Model::get_or_create(channel_id, db).await?;
|
let channel = channel::Model::get_or_create(channel_id, db).await?;
|
||||||
|
|
||||||
|
let timestamp_msg = msg.timestamp.naive_utc();
|
||||||
|
let timestamp: DateTime<Utc> =
|
||||||
|
DateTime::from_timestamp_secs(timestamp_msg.and_utc().timestamp()).unwrap();
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"{}, {}, {}, {}, {}",
|
"{}, {}, {}, {}, {}, {}",
|
||||||
msg.id.get(),
|
msg.id.get(),
|
||||||
member,
|
member,
|
||||||
server,
|
server,
|
||||||
|
timestamp,
|
||||||
content,
|
content,
|
||||||
channel
|
channel
|
||||||
);
|
);
|
||||||
@@ -46,11 +52,12 @@ pub async fn log_message(
|
|||||||
let activeModel = messages::ActiveModel {
|
let activeModel = messages::ActiveModel {
|
||||||
id: sea_orm::ActiveValue::NotSet,
|
id: sea_orm::ActiveValue::NotSet,
|
||||||
id_discord: sea_orm::ActiveValue::Set(msg.id.get() as i64),
|
id_discord: sea_orm::ActiveValue::Set(msg.id.get() as i64),
|
||||||
|
timestamp: sea_orm::ActiveValue::Set(timestamp),
|
||||||
id_sender: sea_orm::ActiveValue::Set(member),
|
id_sender: sea_orm::ActiveValue::Set(member),
|
||||||
id_server: sea_orm::ActiveValue::Set(server),
|
id_server: sea_orm::ActiveValue::Set(server),
|
||||||
id_content: sea_orm::ActiveValue::Set(content),
|
id_content: sea_orm::ActiveValue::Set(content),
|
||||||
id_channel: sea_orm::ActiveValue::Set(channel),
|
id_channel: sea_orm::ActiveValue::Set(channel),
|
||||||
};
|
};
|
||||||
activeModel.insert(db).await;
|
activeModel.insert(db).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ impl EventHandler for Bot {
|
|||||||
println!("Error sending message: {why:?}");
|
println!("Error sending message: {why:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log_message(&self.db, &ctx, msg).await;
|
log_message(&self.db, &ctx, msg).await.unwrap();
|
||||||
}
|
}
|
||||||
async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
|
async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
|
||||||
if let Interaction::Command(command) = interaction {
|
if let Interaction::Command(command) = interaction {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use sea_orm::entity::prelude::*;
|
|||||||
pub struct Model {
|
pub struct Model {
|
||||||
#[sea_orm(primary_key)]
|
#[sea_orm(primary_key)]
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
|
pub timestamp: DateTimeUtc,
|
||||||
#[sea_orm(unique)]
|
#[sea_orm(unique)]
|
||||||
pub id_discord: i64,
|
pub id_discord: i64,
|
||||||
pub id_sender: i32,
|
pub id_sender: i32,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ impl MigrationTrait for Migration {
|
|||||||
.col(big_integer(Messages::IdDiscord))
|
.col(big_integer(Messages::IdDiscord))
|
||||||
.col(integer(Messages::IdSender))
|
.col(integer(Messages::IdSender))
|
||||||
.col(integer(Messages::IdContent))
|
.col(integer(Messages::IdContent))
|
||||||
|
.col(timestamp(Messages::Timestamp))
|
||||||
.foreign_key(
|
.foreign_key(
|
||||||
ForeignKey::create()
|
ForeignKey::create()
|
||||||
.from(Messages::Table, Messages::IdContent)
|
.from(Messages::Table, Messages::IdContent)
|
||||||
@@ -46,6 +47,7 @@ impl MigrationTrait for Migration {
|
|||||||
enum Messages {
|
enum Messages {
|
||||||
Table,
|
Table,
|
||||||
Id,
|
Id,
|
||||||
|
Timestamp,
|
||||||
IdDiscord,
|
IdDiscord,
|
||||||
IdSender,
|
IdSender,
|
||||||
IdContent,
|
IdContent,
|
||||||
|
|||||||
Reference in New Issue
Block a user