From 020de4d0b8a0e3432fc14ae8455fe3061e635e0f Mon Sep 17 00:00:00 2001 From: Stachelbeere1248 Date: Mon, 14 Oct 2024 12:15:08 +0200 Subject: [PATCH] clean-up old zmp server ids --- src/commands/command_helper.rs | 10 ++- src/commands/helpstart.rs | 1 - src/commands/lfg.rs | 115 +++++++++------------------------ src/main.rs | 2 +- 4 files changed, 39 insertions(+), 89 deletions(-) diff --git a/src/commands/command_helper.rs b/src/commands/command_helper.rs index b801d0d..6ec34c8 100644 --- a/src/commands/command_helper.rs +++ b/src/commands/command_helper.rs @@ -31,8 +31,12 @@ pub(crate) fn cooldown(ctx: &Context, user: u64, guild: u64) -> Result<(), Error member: None, __non_exhaustive: (), }; - match cooldown_tracker.remaining_cooldown((*ctx).cooldown_context(), &cooldown_durations) { - Some(remaining) => Err(format!("Please wait {} seconds", remaining.as_secs()).into()), - None => Ok(cooldown_tracker.start_cooldown((*ctx).cooldown_context())), + if ctx.framework().options.owners.contains(&ctx.author().id) { + Ok(()) + } else { + match cooldown_tracker.remaining_cooldown((*ctx).cooldown_context(), &cooldown_durations) { + Some(remaining) => Err(format!("Please wait {} seconds", remaining.as_secs()).into()), + None => Ok(cooldown_tracker.start_cooldown((*ctx).cooldown_context())), + } } } diff --git a/src/commands/helpstart.rs b/src/commands/helpstart.rs index 0c267fa..d4efdd4 100644 --- a/src/commands/helpstart.rs +++ b/src/commands/helpstart.rs @@ -19,7 +19,6 @@ pub(crate) async fn helpstart( let mut reply = CreateReply::default(); let ping = match g { 1256217633959841853_u64 => 1257411572092113017_u64, - 995300932164276234_u64 => 1008075054971621448_u64, _ => 0_u64 }; diff --git a/src/commands/lfg.rs b/src/commands/lfg.rs index 2922fe4..449d274 100644 --- a/src/commands/lfg.rs +++ b/src/commands/lfg.rs @@ -1,6 +1,5 @@ use poise::{ChoiceParameter, CreateReply}; use serenity::all::{CreateAllowedMentions, RoleId}; - //from main.rs use crate::commands::command_helper::cooldown; use crate::{Context, Error}; @@ -72,8 +71,8 @@ pub(crate) async fn lfg( #[rename = "message"] note: Option, ) -> Result<(), Error> { - let mut reply: CreateReply = CreateReply::default(); let guild_id = ctx.guild_id().unwrap().get(); + let mut reply: CreateReply = CreateReply::default(); reply = match cooldown(&ctx, 600, 300) { Ok(_) => { let current: u8 = current_players.unwrap_or(1); @@ -82,18 +81,6 @@ pub(crate) async fn lfg( desired = 4 } let map_name: &str = map.name(); - let old_ping: u64 = match mode { - Casual => match map { - DeadEnd => 1005837123921915914, - BadBlood => 1140190470698438666, - AlienArcadium => 1105917281898336356, - Prison => 1253440747454333009, - }, - Speedrun => 1005836989595144243, - Challenge => 1005836864680361994, - Event => 1175116511095050331, - //Tournament => 1210508966036242445, - }; let new_ping: u64 = match mode { Casual => match map { DeadEnd => 1257408106783178752, @@ -108,7 +95,6 @@ pub(crate) async fn lfg( }; let ping = match guild_id { 1256217633959841853 => new_ping, - 995300932164276234 => old_ping, _ => 0, }; let difficulty: Difficulty = match map { @@ -144,13 +130,15 @@ pub(crate) async fn lfg( Ok(()) } #[derive(Debug, poise::ChoiceParameter)] -enum Expert { +enum ExpertMap { #[name = "Dead End"] DeadEnd, #[name = "Bad Blood"] BadBlood, #[name = "Alien Arcadium"] AlienArcadium, + //#[name = "Prison"] + //Prison, #[name = "Speedrun"] Speedrun, } @@ -158,7 +146,7 @@ enum Expert { pub(crate) async fn expert( ctx: Context<'_>, - #[rename = "map"] mode: Expert, + #[rename = "map"] mode: ExpertMap, #[min = 1_u8] #[max = 3_u8] @@ -183,77 +171,24 @@ pub(crate) async fn expert( let current: u8 = current_players.unwrap_or(1); let mut desired: u8 = desired_players.unwrap_or(4); if current >= desired { - desired = 4 - } - //TODO ZMPv2 + desired = 4; + }; let (ping, allowed_roles): (u64, Vec) = match mode { - Expert::Speedrun => ( - 1243676538067488828, - vec![ - 1235975301461184513, - 1235975620400386172, - 1235975954413654167, - 1235976165345329162, - 1235976366109753404, - 1235967416605872179, - 1235967676048740434, - 1235968713354907648, - 1235968958511841351, - 1235969159679180860, - 1236226368052658217, - 1173396223592513647, - ], + ExpertMap::Speedrun => ( + 1295322375637958716, + ROLE_LIST.iter().skip(2).map(|tier| [tier[4], tier[5]]).flatten().collect() ), - Expert::DeadEnd => ( - 1243675610895880366, - vec![ - 1235975562498015354, - 1235975873187020900, - 1235976093517746227, - 1235976301702156359, - 1235976469683896441, - 1235967416605872179, - 1235967676048740434, - 1235968713354907648, - 1235968958511841351, - 1235969159679180860, - 1236226368052658217, - 1173396223592513647, - ], + ExpertMap::DeadEnd => ( + 1295321319344177172, + ROLE_LIST.iter().skip(2).map(|tier| [tier[1], tier[5]]).flatten().collect() ), - Expert::BadBlood => ( - 1243676387634708491, - vec![ - 1235975518529261599, - 1235975747219357706, - 1235976055769268274, - 1235976257414631464, - 1235976434724376728, - 1235967416605872179, - 1235967676048740434, - 1235968713354907648, - 1235968958511841351, - 1235969159679180860, - 1236226368052658217, - 1173396223592513647, - ], + ExpertMap::BadBlood => ( + 1295322259631640607, + ROLE_LIST.iter().skip(2).map(|tier| [tier[2], tier[5]]).flatten().collect() ), - Expert::AlienArcadium => ( - 1243676465829249116, - vec![ - 1235975471968157851, - 1235975697487364237, - 1235975991617130567, - 1235976216469835926, - 1235976398380863549, - 1235967416605872179, - 1235967676048740434, - 1235968713354907648, - 1235968958511841351, - 1235969159679180860, - 1236226368052658217, - 1173396223592513647, - ], + ExpertMap::AlienArcadium => ( + 1295322327910842441, + ROLE_LIST.iter().skip(2).map(|tier| [tier[3], tier[5]]).flatten().collect() ), }; let is_expert: bool = ctx @@ -282,3 +217,15 @@ pub(crate) async fn expert( } Ok(()) } + +const ROLE_LIST: [[u64;6]; 9] = [ // [[basic, de, bb, aa, sr, star]; 9] + [1256229103678259311, 1256229192744304670, 1256229223450935377, 1256229498899271754, 1256229540900900996, 1256229575269154866], //novice + [1256230831131983932, 1256230750827577447, 1256230776828334143, 1256230793630715975, 1256230818444214333, 1256230734642024468], //seasoned + [1256230723455553556, 1256230653083521045, 1256230666786443310, 1256230686214324255, 1256230704061353995, 1256230636721537097], //expert + [1256230625635995718, 1256230573203128370, 1256230582908747776, 1256230600025706506, 1256230610998005872, 1256230557897986068], //pro + [1256230543532626002, 1256230480823582861, 1256230502273126421, 1256230515355160597, 1256230531478065243, 1256230463241191494], //master + [1256230442907074703, 1256230359419588700, 1256230396719403141, 1256230416516649012, 1256230429212545025, 1256230346848997396], //grandmaster + [1256230332169060362, 1256230266889044020, 1256230288888168458, 1256230416516649012, 1256230316528631870, 1256230242943766651], //legend + [1256230231732387950, 1256230157967163495, 1256230181199151254, 1256230194499420223, 1256230207099244646, 1256230102627258449], //divine + [1256230002597302322, 1256229873064869939, 1256229929247440906, 1256229963166646314, 1256229982569627792, 1256229672598110218], //goat +]; diff --git a/src/main.rs b/src/main.rs index 096ad72..f0cac39 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,7 +90,7 @@ async fn main() { GatewayIntents::non_privileged() | GatewayIntents::MESSAGE_CONTENT | GatewayIntents::GUILD_MEMBERS; let client = serenity::ClientBuilder::new(token, intents) .framework(framework) - .activity(ActivityData::playing("arcade_zombies_prison")) + .activity(ActivityData::custom("NPC moment...")) .await; client.unwrap().start_autosharded().await.unwrap() }