Skip to content

Commit

Permalink
New command: ~msync (#25)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Crd5 authored Oct 18, 2024
1 parent 0f65ccf commit dcb09bf
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/commands/discord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/does_my_game_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/commands/game_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
Expand Down
16 changes: 6 additions & 10 deletions src/commands/heroic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/).";
Expand All @@ -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;
Expand All @@ -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?;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pub mod discord;
pub mod username;
pub mod heroic;
pub mod whats_where;
pub mod msync;
28 changes: 28 additions & 0 deletions src/commands/msync.rs
Original file line number Diff line number Diff line change
@@ -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(())
}

9 changes: 6 additions & 3 deletions src/commands/username.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/website.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/whats_where.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,7 +48,8 @@ async fn serenity(
say(),
username(),
heroic(),
whats_where()
whats_where(),
msync()
],
prefix_options: poise::PrefixFrameworkOptions {
prefix: Some("~".into()),
Expand Down

0 comments on commit dcb09bf

Please sign in to comment.