Verified Commit c1a92e8b authored by Mathias B.'s avatar Mathias B.
Browse files

Synchronisation de la création du rôle durant l'exécution du bot

parent 8970ce17
use crate::modules::synchrotron;
use crate::repositories::ChannelRepository;
use crate::repositories::{ChannelRepository, RoleRepository};
use crate::repositories::MemberRepository;
use crate::repositories::UserRepository;
use crate::repositories::{GuildRepository, TicketRepository};
use crate::utils::functions;
use chrono::Utc;
use datastructs::discord::{ChannelData, UserData};
use datastructs::discord::{ChannelData, UserData, RoleData};
use serenity::async_trait;
use serenity::model::prelude::*;
use serenity::prelude::*;
......@@ -166,6 +166,10 @@ impl EventHandler for Handler {
}
}
async fn guild_role_create(&self, _ctx: Context, _guild_id: GuildId, new: Role) {
process_handler_result(RoleRepository::create(&RoleData::from(&role)).await);
}
async fn guild_role_delete(
&self,
_ctx: Context,
......
INSERT INTO discord.roles(id, name, guilds_id, position, managed) VALUES ($1, $2, $3, $4, $5)
\ No newline at end of file
......@@ -51,6 +51,21 @@ impl RoleRepository {
Ok(rows.iter().map(|row| RoleId(row.get::<_, i64>("id") as u64)).collect_vec())
}
pub async fn create(role: &RoleData) -> super::PostgreSQLResult<()> {
let db = DatabaseClient::get();
db.execute(
include_str!("../files/sql/roles/insert.sql"),
&[
&role.id,
&role.name,
&role.guild_id,
&role.position,
&role.managed
]
).await.map(|_| ())
}
pub async fn copy_temporary_roles(
temp_table_id: u32,
roles: &[RoleData],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment