Skip to content

Commit

Permalink
General, embed and level commands restructuring
Browse files Browse the repository at this point in the history
NOTE: also moved the uptime command in the embed_commands module.
  • Loading branch information
1Git2Clone committed Jul 10, 2024
1 parent a770601 commit 29bbe27
Show file tree
Hide file tree
Showing 29 changed files with 1,019 additions and 938 deletions.
745 changes: 0 additions & 745 deletions src/commands/embed_commands.rs

This file was deleted.

21 changes: 21 additions & 0 deletions src/commands/embed_commands/avatar.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use super::*;

/// Get the avatar for someone.
#[poise::command(slash_command, prefix_command, rename = "avatar")]
pub async fn avatar(
ctx: Context<'_>,
#[description = "Selected user"] user: Option<serenity::User>,
) -> Result<(), Error> {
let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await);
let response: String = format!("**{}**'s avatar:", target_replied_user.name);
let user_avatar_as_embed: String = target_replied_user.face().replace(".webp", ".png");

let embed = serenity::CreateEmbed::new()
.title(response)
.color((255, 0, 0))
.image(user_avatar_as_embed);
let full_respone = poise::CreateReply::default().embed(embed);
ctx.send(full_respone).await?;

Ok(())
}
57 changes: 57 additions & 0 deletions src/commands/embed_commands/bonk.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use super::*;

/// Bonk someone who's horknee
#[poise::command(prefix_command, slash_command, rename = "bonk")]
pub async fn bonk(
ctx: Context<'_>,
#[description = "Selected user"] user: Option<serenity::User>,
) -> Result<(), Error> {
let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await);
let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Bonk).await?;
let bot_user = Arc::clone(&ctx.data().bot_user);
if target_replied_user == ctx.author() {
ctx.send(
poise::CreateReply::default().content("バカ!").embed(
serenity::CreateEmbed::new()
.color((255, 0, 0))
.image(embed_item.to_string())
.footer(
serenity::CreateEmbedFooter::new(bot_user.tag())
.icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()),
),
),
)
.await?;
return Ok(());
}

let response: String = format!(
"**{}** *bonks* **{}**",
ctx.author().name,
target_replied_user.name
);

let ping_on_shash_command: Option<poise::serenity_prelude::Mention> = match ctx {
poise::Context::Prefix(_) => None,
poise::Context::Application(_) => Some(target_replied_user.mention()),
};

let embed = serenity::CreateEmbed::new()
.title(response)
.color((255, 0, 0))
.image(embed_item.to_string())
.footer(
serenity::CreateEmbedFooter::new(bot_user.tag())
.icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()),
);

let full_respone = poise::CreateReply::default()
.content(match ping_on_shash_command {
Some(ping) => format!("{}", ping),
None => "".to_owned(),
})
.embed(embed);
ctx.send(full_respone).await?;

Ok(())
}
20 changes: 20 additions & 0 deletions src/commands/embed_commands/boom.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use super::*;

/// Just try it.
#[poise::command(slash_command, prefix_command, rename = "boom")]
pub async fn boom(ctx: Context<'_>) -> Result<(), Error> {
let bot_user = Arc::clone(&ctx.data().bot_user);
let bot_avatar = bot_user.face().replace(".webp", ".png");

ctx.send(
poise::CreateReply::default().embed(
serenity::CreateEmbed::default()
.image("https://raw.githubusercontent.com/1Git2Clone/serenity-discord-bot/main/src/assets/hu_boom.jpg")
.color((255, 0, 0))
.footer(serenity::CreateEmbedFooter::new(bot_user.tag()).icon_url(bot_avatar)),
),
)
.await?;

Ok(())
}
50 changes: 50 additions & 0 deletions src/commands/embed_commands/bury.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
use super::*;

/// Bury someone
#[poise::command(prefix_command, slash_command, rename = "bury")]
pub async fn bury(
ctx: Context<'_>,
#[description = "Selected user"] user: Option<serenity::User>,
) -> Result<(), Error> {
let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await);
let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Bury).await?;
if target_replied_user == ctx.author() {
ctx.send(poise::CreateReply::default().content(format!(
"{} Just use the `!selfbury` or `/selfbury` command bruh...",
target_replied_user.mention()
)))
.await?;
return Ok(());
}

let response: String = format!(
"**{}** *buries* **{}**",
ctx.author().name,
target_replied_user.name
);

let ping_on_shash_command: Option<poise::serenity_prelude::Mention> = match ctx {
poise::Context::Prefix(_) => None,
poise::Context::Application(_) => Some(target_replied_user.mention()),
};
let bot_user = Arc::clone(&ctx.data().bot_user);

let embed = serenity::CreateEmbed::new()
.title(response)
.color((255, 0, 0))
.image(embed_item.to_string())
.footer(
serenity::CreateEmbedFooter::new(bot_user.tag())
.icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()),
);

let full_respone = poise::CreateReply::default()
.content(match ping_on_shash_command {
Some(ping) => format!("{}", ping),
None => "".to_owned(),
})
.embed(embed);
ctx.send(full_respone).await?;

Ok(())
}
21 changes: 21 additions & 0 deletions src/commands/embed_commands/chair.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use super::*;

/// Get a motivation chair GIF
#[poise::command(slash_command, prefix_command, rename = "chair")]
pub async fn chair(ctx: Context<'_>) -> Result<(), Error> {
let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Chair).await?;
let bot_user = Arc::clone(&ctx.data().bot_user);

let embed = serenity::CreateEmbed::new()
.title("You need some motivation!")
.color((255, 0, 0))
.image(embed_item)
.footer(
serenity::CreateEmbedFooter::new(bot_user.tag())
.icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()),
);
let full_respone = poise::CreateReply::default().embed(embed);
ctx.send(full_respone).await?;

Ok(())
}
16 changes: 16 additions & 0 deletions src/commands/embed_commands/drive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use super::*;

/// Get a Ryan Gosling drive GIF.
#[poise::command(slash_command, prefix_command, rename = "drive")]
pub async fn drive(ctx: Context<'_>) -> Result<(), Error> {
let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::RyanGoslingDrive).await?;

let embed = serenity::CreateEmbed::new()
// .title()
.color((255, 0, 0))
.image(embed_item);
let full_respone = poise::CreateReply::default().embed(embed);
ctx.send(full_respone).await?;

Ok(())
}
59 changes: 59 additions & 0 deletions src/commands/embed_commands/hug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use super::*;

/// Hug someone
#[poise::command(prefix_command, slash_command, rename = "hug")]
pub async fn hug(
ctx: Context<'_>,
#[description = "Selected user"] user: Option<serenity::User>,
) -> Result<(), Error> {
let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await);
let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Hug).await?;
let bot_user = Arc::clone(&ctx.data().bot_user);
if target_replied_user == ctx.author() {
ctx.send(
poise::CreateReply::default()
.content("Aww~ I'll hug you!")
.embed(
serenity::CreateEmbed::new()
.color((255, 0, 0))
.image(embed_item.to_string())
.footer(
serenity::CreateEmbedFooter::new(bot_user.tag())
.icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()),
),
),
)
.await?;
return Ok(());
}

let response: String = format!(
"**{}** *hugs* **{}**",
ctx.author().name,
target_replied_user.name
);

let ping_on_shash_command: Option<poise::serenity_prelude::Mention> = match ctx {
poise::Context::Prefix(_) => None,
poise::Context::Application(_) => Some(target_replied_user.mention()),
};

let embed = serenity::CreateEmbed::new()
.title(response)
.color((255, 0, 0))
.image(embed_item.to_string())
.footer(
serenity::CreateEmbedFooter::new(bot_user.tag())
.icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()),
);

let full_respone = poise::CreateReply::default()
.content(match ping_on_shash_command {
Some(ping) => format!("{}", ping),
None => "".to_owned(),
})
.embed(embed);
ctx.send(full_respone).await?;

Ok(())
}
51 changes: 51 additions & 0 deletions src/commands/embed_commands/kick.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use super::*;

/// Kick someone
#[poise::command(prefix_command, slash_command, rename = "kick")]
pub async fn kick(
ctx: Context<'_>,
#[description = "Selected user"] user: Option<serenity::User>,
) -> Result<(), Error> {
let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await);
let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Kick).await?;
if target_replied_user == ctx.author() {
ctx.send(poise::CreateReply::default().content(format!(
"{}, why would you kick yourself...? Weirdo...",
target_replied_user.mention()
)))
.await?;
return Ok(());
}

let response: String = format!(
"**{}** *kicks* **{}**",
ctx.author().name,
target_replied_user.name
);

let ping_on_shash_command: Option<poise::serenity_prelude::Mention> = match ctx {
poise::Context::Prefix(_) => None,
poise::Context::Application(_) => Some(target_replied_user.mention()),
};

let bot_user = Arc::clone(&ctx.data().bot_user);

let embed = serenity::CreateEmbed::new()
.title(response)
.color((255, 0, 0))
.image(embed_item.to_string())
.footer(
serenity::CreateEmbedFooter::new(bot_user.tag())
.icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()),
);

let full_respone = poise::CreateReply::default()
.content(match ping_on_shash_command {
Some(ping) => format!("{}", ping),
None => "".to_owned(),
})
.embed(embed);
ctx.send(full_respone).await?;

Ok(())
}
48 changes: 48 additions & 0 deletions src/commands/embed_commands/kill.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use super::*;

/// Kill someone (Sadge)
#[poise::command(prefix_command, slash_command, rename = "kill")]
pub async fn kill(
ctx: Context<'_>,
#[description = "Selected user"] user: Option<serenity::User>,
) -> Result<(), Error> {
let target_replied_user = user.as_ref().unwrap_or(get_replied_user(ctx).await);
let embed_item: &str = cmd_utils::get_embed_from_type(&EmbedType::Kill).await?;
if target_replied_user == ctx.author() {
ctx.send(poise::CreateReply::default().content("No."))
.await?;
return Ok(());
}

let response: String = format!(
"**{}** *kills* **{}**",
ctx.author().name,
target_replied_user.name
);

let ping_on_shash_command: Option<poise::serenity_prelude::Mention> = match ctx {
poise::Context::Prefix(_) => None,
poise::Context::Application(_) => Some(target_replied_user.mention()),
};

let bot_user = Arc::clone(&ctx.data().bot_user);

let embed = serenity::CreateEmbed::new()
.title(response)
.color((255, 0, 0))
.image(embed_item.to_string())
.footer(
serenity::CreateEmbedFooter::new(bot_user.tag())
.icon_url(Arc::clone(&ctx.data().bot_avatar).to_string()),
);

let full_respone = poise::CreateReply::default()
.content(match ping_on_shash_command {
Some(ping) => format!("{}", ping),
None => "".to_owned(),
})
.embed(embed);
ctx.send(full_respone).await?;

Ok(())
}
Loading

0 comments on commit 29bbe27

Please sign in to comment.