use std::sync::Arc; use twilight_model::{channel::message::Embed, oauth::Application}; use twilight_util::builder::embed::{ EmbedAuthorBuilder, EmbedBuilder, EmbedFieldBuilder, EmbedFooterBuilder, ImageSource, }; use crate::{ constants::{COLOR_RED, COLOR_YELLOW}, database::models::Message, discord::images, groups::calls::moderation::Rule, utils::ellipse, }; pub fn first_warning_embed( app: &Application, message: &Message, rules_broken: Vec>, ) -> Embed { EmbedBuilder::new() .author( EmbedAuthorBuilder::new(app.name.clone()) .icon_url( ImageSource::url( images::get_avatar_url( app.icon, app.bot.as_ref().unwrap().id.get(), app.bot.as_ref().unwrap().discriminator as u64, None ) ).unwrap() ) ) .title("Warning") .description("You broke [Payphone's code of conduct](https://payphone.lat/code-of-conduct) during a call. Read the code of conduct to prevent getting banned.") .field(EmbedFieldBuilder::new("What message broke the rules?", ellipse(message.data.content.clone(), 500))) .field(EmbedFieldBuilder::new( "What rules did you break?", rules_broken .iter() .map(|rule| format!("- {}", rule.name())) .collect::>() .join("\n"), )) .color(COLOR_YELLOW) .thumbnail( ImageSource::url( images::get_avatar_url( app.icon, app.bot.as_ref().unwrap().id.get(), app.bot.as_ref().unwrap().discriminator as u64, None )) .unwrap() ) .footer(EmbedFooterBuilder::new("This is a warning because it's your first offense. Breaking the rules again will result in a ban.")) .build() } pub fn repeat_warning_embed( app: &Application, message: &Message, rules_broken: Vec>, ) -> Embed { EmbedBuilder::new() .author( EmbedAuthorBuilder::new(app.name.clone()) .icon_url( ImageSource::url( images::get_avatar_url( app.icon, app.bot.as_ref().unwrap().id.get(), app.bot.as_ref().unwrap().discriminator as u64, None ) ).unwrap() ) ) .title("Long Time no See!") .description("You broke [Payphone's code of conduct](https://payphone.lat/code-of-conduct) during a call. It's not your first offense, yet you've gone for a long time with a good record so we're making this a warning instead. In case you've forgotten the rules, consider this a reminder to re-read them.") .field(EmbedFieldBuilder::new("What message broke the rules?", ellipse(message.data.content.clone(), 500))) .field(EmbedFieldBuilder::new( "What rules did you break?", rules_broken .iter() .map(|rule| format!("- {}", rule.name())) .collect::>() .join("\n"), )) .color(COLOR_YELLOW) .thumbnail( ImageSource::url( images::get_avatar_url( app.icon, app.bot.as_ref().unwrap().id.get(), app.bot.as_ref().unwrap().discriminator as u64, None )) .unwrap() ) .footer(EmbedFooterBuilder::new("Breaking the rules again will result in a ban.")) .build() } pub fn first_ban_embed( app: &Application, message: &Message, rules_broken: Vec>, ) -> Embed { EmbedBuilder::new() .author( EmbedAuthorBuilder::new(app.name.clone()) .icon_url( ImageSource::url( images::get_avatar_url( app.icon, app.bot.as_ref().unwrap().id.get(), app.bot.as_ref().unwrap().discriminator as u64, None ) ).unwrap() ) ) .title("Banned") .description("You broke [Payphone's code of conduct](https://payphone.lat/code-of-conduct) during a call. This is your first offense, and as such, you are being issued a ban. This ban will last for 24 hours, next one will be permanent.") .field(EmbedFieldBuilder::new("What message broke the rules?", ellipse(message.data.content.clone(), 500))) .field(EmbedFieldBuilder::new( "What rules did you break?", rules_broken .iter() .map(|rule| format!("- {}", rule.name())) .collect::>() .join("\n"), )) .color(COLOR_RED) .thumbnail( ImageSource::url( images::get_avatar_url( app.icon, app.bot.as_ref().unwrap().id.get(), app.bot.as_ref().unwrap().discriminator as u64, None )) .unwrap() ) .footer(EmbedFooterBuilder::new("Breaking the rules again will result in being permanently banned.")) .build() } pub fn final_ban_embed( app: &Application, message: &Message, rules_broken: Vec>, ) -> Embed { EmbedBuilder::new() .author( EmbedAuthorBuilder::new(app.name.clone()) .icon_url( ImageSource::url( images::get_avatar_url( app.icon, app.bot.as_ref().unwrap().id.get(), app.bot.as_ref().unwrap().discriminator as u64, None ) ).unwrap() ) ) .title("Permanently Banned") .description("You broke [Payphone's code of conduct](https://payphone.lat/code-of-conduct) during a call. This is your final offense, and as such, you are being issued a permanent ban.") .field(EmbedFieldBuilder::new("What message broke the rules?", ellipse(message.data.content.clone(), 500))) .field(EmbedFieldBuilder::new( "What rules did you break?", rules_broken .iter() .map(|rule| format!("- {}", rule.name())) .collect::>() .join("\n"), )) .color(COLOR_RED) .thumbnail( ImageSource::url( images::get_avatar_url( app.icon, app.bot.as_ref().unwrap().id.get(), app.bot.as_ref().unwrap().discriminator as u64, None ) ).unwrap() ) .footer(EmbedFooterBuilder::new("You broke the rules 3 times.")) .build() }