From dcb09bfa978eaa9026a68252738f9233f16dc439 Mon Sep 17 00:00:00 2001 From: Crd5 <62203291+Crd5@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:29:32 +0300 Subject: [PATCH] New command: ~msync (#25) * New command: ~msync Tested on my private server, but still check my code since I'm a junior in Rust * # New command: ~msync # Invoked by is now: - Is a subtitle - Shows how to use the command # Includes hahayup's pr that adds ~paths Tested on my private server, but still check my code since I'm a junior in Rust --- src/commands/discord.rs | 4 ++-- src/commands/does_my_game_work.rs | 4 ++-- src/commands/game_support.rs | 5 ++++- src/commands/github.rs | 6 +++--- src/commands/heroic.rs | 16 ++++++---------- src/commands/mod.rs | 1 + src/commands/msync.rs | 28 ++++++++++++++++++++++++++++ src/commands/username.rs | 9 ++++++--- src/commands/website.rs | 6 +++--- src/commands/whats_where.rs | 4 ++-- src/main.rs | 4 +++- 11 files changed, 60 insertions(+), 27 deletions(-) create mode 100644 src/commands/msync.rs diff --git a/src/commands/discord.rs b/src/commands/discord.rs index 03ffc50..4b7e073 100644 --- a/src/commands/discord.rs +++ b/src/commands/discord.rs @@ -7,13 +7,13 @@ pub async fn discord(ctx: Context<'_>) -> Result<(), Error> { if let Context::Prefix(prefix) = ctx { match prefix.msg.clone().referenced_message { Some(parent) => { - message += "\n\nThis command was invoked by "; - message += ctx.author().to_string().as_str(); + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "discord"); parent.reply_ping(&ctx, message).await?; prefix.msg.delete(ctx).await?; }, None => { + message += &format!("\n-# This command was invoked using `~{}`", "discord"); ctx.reply(message).await?; } } diff --git a/src/commands/does_my_game_work.rs b/src/commands/does_my_game_work.rs index ebd0bb1..156b409 100644 --- a/src/commands/does_my_game_work.rs +++ b/src/commands/does_my_game_work.rs @@ -18,13 +18,13 @@ As a reminder: Most games with EasyAntiCheat and most other anti-cheats will **N if let Context::Prefix(prefix) = ctx { match prefix.msg.clone().referenced_message { Some(parent) => { - message += "\n\nThis command was invoked by "; - message += ctx.author().to_string().as_str(); + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "does_my_game_work"); parent.reply_ping(&ctx, message).await?; prefix.msg.delete(ctx).await?; }, None => { + message += &format!("\n-# This command was invoked using `~{}`", "does_my_game_work"); ctx.reply(message).await?; } } diff --git a/src/commands/game_support.rs b/src/commands/game_support.rs index 46185ec..78c9c74 100644 --- a/src/commands/game_support.rs +++ b/src/commands/game_support.rs @@ -46,10 +46,13 @@ pub async fn game_support(ctx: Context<'_>, if let Context::Prefix(prefix) = ctx { match prefix.msg.clone().referenced_message { Some(parent) => { - parent.reply(&ctx, message).await?; + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "game_support"); + + parent.reply_ping(&ctx, message).await?; prefix.msg.delete(ctx).await?; }, None => { + message += &format!("\n-# This command was invoked using `~{}`", "game_support"); ctx.reply(message).await?; } } diff --git a/src/commands/github.rs b/src/commands/github.rs index 99bd59b..0268dbf 100644 --- a/src/commands/github.rs +++ b/src/commands/github.rs @@ -7,13 +7,13 @@ pub async fn github(ctx: Context<'_>) -> Result<(), Error> { if let Context::Prefix(prefix) = ctx { match prefix.msg.clone().referenced_message { Some(parent) => { - message += "\n\nThis command was invoked by "; - message += ctx.author().to_string().as_str(); - + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "github"); + parent.reply_ping(&ctx, message).await?; prefix.msg.delete(ctx).await?; }, None => { + message += &format!("\n-# This command was invoked using `~{}`", "github"); ctx.reply(message).await?; } } diff --git a/src/commands/heroic.rs b/src/commands/heroic.rs index dbd48d6..6b32912 100644 --- a/src/commands/heroic.rs +++ b/src/commands/heroic.rs @@ -2,7 +2,6 @@ use crate::{Context, Error}; #[poise::command(prefix_command, slash_command, aliases("epic", "gog", "amazon", "prime"))] pub async fn heroic(ctx: Context<'_>) -> Result<(), Error> { - let default_message = "To use Whisky in the [Heroic Games Launcher](https://heroicgameslauncher.com/), follow these instructions:"; let epic = "To play games on the Epic Games Launcher, use [Heroic](https://heroicgameslauncher.com/)."; @@ -18,18 +17,15 @@ pub async fn heroic(ctx: Context<'_>) -> Result<(), Error> { message += default_message; message += "\n\n"; message += bigmessage; - } - else if cmd_name == "epic" { + } else if cmd_name == "epic" { message += epic; message += "\n\n"; message += bigmessage; - } - else if cmd_name == "gog" { + } else if cmd_name == "gog" { message += gog; message += "\n\n"; message += bigmessage; - } - else if cmd_name == "amazon" || cmd_name == "prime" { + } else if cmd_name == "amazon" || cmd_name == "prime" { message += amazon; message += "\n\n"; message += bigmessage; @@ -38,13 +34,13 @@ pub async fn heroic(ctx: Context<'_>) -> Result<(), Error> { if let Context::Prefix(prefix) = ctx { match prefix.msg.clone().referenced_message { Some(parent) => { - message += "\n\nThis command was invoked by "; - message += ctx.author().to_string().as_str(); + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "heroic"); parent.reply_ping(&ctx, message).await?; prefix.msg.delete(ctx).await?; - }, + } None => { + message += &format!("\n-# This command was invoked using `~{}`", "heroic"); ctx.reply(message).await?; } } diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 3e007ef..d0bfe67 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -8,3 +8,4 @@ pub mod discord; pub mod username; pub mod heroic; pub mod whats_where; +pub mod msync; diff --git a/src/commands/msync.rs b/src/commands/msync.rs new file mode 100644 index 0000000..7ef830d --- /dev/null +++ b/src/commands/msync.rs @@ -0,0 +1,28 @@ +use crate::{Context, Error}; + +#[poise::command(prefix_command, slash_command)] +pub async fn msync(ctx: Context<'_>) -> Result<(), Error> { + let mut message = "## Steam download stops? +1. Kill All Bottles: Press `Command`⌘ + `Shift`⇧ + `K` or Go to `File` (near the Apple logo) -> `Kill All Bottles` +2. Change MSync to ESync: `Bottle Configuration` -> `Enhanced Sync` +3. Run Steam".to_owned(); + + if let Context::Prefix(prefix) = ctx { + match prefix.msg.clone().referenced_message { + Some(parent) => { + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "msync"); + + parent.reply_ping(&ctx, message).await?; + prefix.msg.delete(ctx).await?; + }, + None => { + message += &format!("\n-# This command was invoked using `~{}`", "msync"); + ctx.reply(message).await?; + } + } + } else { + ctx.reply(message).await?; + } + Ok(()) +} + diff --git a/src/commands/username.rs b/src/commands/username.rs index 373844b..e6dea56 100644 --- a/src/commands/username.rs +++ b/src/commands/username.rs @@ -2,17 +2,20 @@ use crate::{Context, Error}; #[poise::command(prefix_command, slash_command)] pub async fn username(ctx: Context<'_>) -> Result<(), Error> { - let message = "Your username contains a `.` which is a special character. This can cause issues with Wine. + let mut message = "Your username contains a `.` which is a special character. This can cause issues with Wine. -Follow this Apple support guide to change your username: https://support.apple.com/en-us/102547"; +Follow this Apple support guide to change your username: https://support.apple.com/en-us/102547".to_owned(); if let Context::Prefix(prefix) = ctx { match prefix.msg.clone().referenced_message { Some(parent) => { - parent.reply(&ctx, message).await?; + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "username"); + + parent.reply_ping(&ctx, message).await?; prefix.msg.delete(ctx).await?; }, None => { + message += &format!("\n-# This command was invoked using `~{}`", "username"); ctx.reply(message).await?; } } diff --git a/src/commands/website.rs b/src/commands/website.rs index dbdc5d3..328d3b9 100644 --- a/src/commands/website.rs +++ b/src/commands/website.rs @@ -7,13 +7,13 @@ pub async fn website(ctx: Context<'_>) -> Result<(), Error> { if let Context::Prefix(prefix) = ctx { match prefix.msg.clone().referenced_message { Some(parent) => { - message += "\n\nThis command was invoked by "; - message += ctx.author().to_string().as_str(); - + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "website"); + parent.reply_ping(&ctx, message).await?; prefix.msg.delete(ctx).await?; }, None => { + message += &format!("\n-# This command was invoked using `~{}`", "website"); ctx.reply(message).await?; } } diff --git a/src/commands/whats_where.rs b/src/commands/whats_where.rs index c0da529..25628e1 100644 --- a/src/commands/whats_where.rs +++ b/src/commands/whats_where.rs @@ -51,13 +51,13 @@ pub async fn whats_where(ctx: Context<'_>) -> Result<(), Error> { if let Context::Prefix(prefix) = ctx { match prefix.msg.clone().referenced_message { Some(parent) => { - message += "\n\nThis command was invoked by "; - message += ctx.author().to_string().as_str(); + message += &format!("\n-# This command was invoked by {} using `~{}`", ctx.author().to_string().as_str(), "whats_where"); parent.reply_ping(&ctx, message).await?; prefix.msg.delete(ctx).await?; }, None => { + message += &format!("\n-# This command was invoked using `~{}`", "whats_where"); ctx.reply(message).await?; } } diff --git a/src/main.rs b/src/main.rs index d3d77b4..904abbd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,7 @@ use crate::commands::say::*; use crate::commands::username::*; use crate::commands::heroic::*; use crate::commands::whats_where::*; +use crate::commands::msync::*; pub mod header; mod commands; @@ -47,7 +48,8 @@ async fn serenity( say(), username(), heroic(), - whats_where() + whats_where(), + msync() ], prefix_options: poise::PrefixFrameworkOptions { prefix: Some("~".into()),