yeehaw square

This commit is contained in:
2024-10-10 23:15:37 -04:00
parent 8e430ef78e
commit 7d591197b0

View File

@@ -13,21 +13,25 @@ async fn ping(ctx: Context<'_>) -> Result<(), Error> {
let start = Instant::now(); let start = Instant::now();
let msg = ctx.say("Pong! \u{1F3D3}").await?; let msg = ctx.say("Pong! \u{1F3D3}").await?;
let time = start.elapsed();
msg.edit(ctx, poise::reply::CreateReply::default() msg.edit(ctx, poise::reply::CreateReply::default()
.content(format!("Pong! \u{1F3D3}\nREST: {:.2?}\nGateway: {:.2?}", .content(format!("Pong! \u{1F3D3}\nREST: {:.2?}\nGateway: {:.2?}",
start.elapsed(), ctx.ping().await))).await?; time, ctx.ping().await))).await?;
Ok(()) Ok(())
} }
fn get_dox_output(ctx: &mut Context<'_>, user: &serenity::User, member: Option<&serenity::Member>, show_permissions: bool) -> String { fn get_dox_output(ctx: &mut Context<'_>,
if user.bot { user: &serenity::User,
return "This user is a bot.".into(); member: Option<&serenity::Member>,
} show_permissions: bool) -> String {
let mut output = String::new(); let mut output = String::new();
if user.bot {
output.push_str("This user is a bot.\n");
}
output.push_str(&format!("**User ID**: {}\n", user.id)); output.push_str(&format!("**User ID**: {}\n", user.id));
if let Some(locale) = &user.locale { if let Some(locale) = &user.locale {
@@ -45,15 +49,12 @@ fn get_dox_output(ctx: &mut Context<'_>, user: &serenity::User, member: Option<&
} }
if let Some(Some(premium_since)) = member.as_ref().map(|m| m.premium_since) { if let Some(Some(premium_since)) = member.as_ref().map(|m| m.premium_since) {
output.push_str(&format!("**Boosting this Server**: Yes\n**Boosting since**: {premium_since}\n")); output.push_str(
&format!("**Boosting this Server**: Yes\n**Boosting since**: {premium_since}\n"));
} }
if show_permissions { if let Some(Ok(permissions)) = member.map(|m| m.permissions(ctx)).filter(|_| show_permissions) {
if let Some(member) = member { output.push_str(&format!("**Permissions**: {}\n", permissions.get_permission_names().join(", ")))
if let Ok(permissions) = member.permissions(ctx) {
output.push_str(&format!("**Permissions**: {}\n", permissions.get_permission_names().join(", ")))
}
}
} }
output output
@@ -90,10 +91,16 @@ async fn dox(
/// Pardner /// Pardner
#[poise::command(slash_command)] #[poise::command(slash_command)]
async fn yeehaw(ctx: Context<'_>, count: Option<u8>) -> Result<(), Error> { async fn yeehaw(ctx: Context<'_>,
ctx.reply(iter::repeat("\u{1F920}") #[min = 1]
.take(count.unwrap_or(1) as usize) #[max = 64]
.collect::<Vec<&str>>() width: usize,
#[min = 1]
#[max = 100]
height: usize) -> Result<(), Error> {
ctx.reply(iter::repeat("\u{1F920}".to_string().repeat(width))
.take(height)
.collect::<Vec<String>>()
.join("\n")).await?; .join("\n")).await?;
Ok(()) Ok(())
} }