style: use tabs over spaces

This commit is contained in:
seth 2024-01-08 14:56:37 -05:00
parent f2979d4cde
commit f0550dd429
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
41 changed files with 1112 additions and 1109 deletions

View file

@ -6,8 +6,8 @@ use color_eyre::eyre::Result;
/// It's a joke
#[poise::command(slash_command, prefix_command)]
pub async fn joke(ctx: Context<'_>) -> Result<()> {
let joke = dadjoke::get_joke().await?;
let joke = dadjoke::get_joke().await?;
ctx.reply(joke).await?;
Ok(())
ctx.reply(joke).await?;
Ok(())
}

View file

@ -5,22 +5,22 @@ use color_eyre::eyre::{eyre, Result};
/// Returns the number of members in the server
#[poise::command(slash_command, prefix_command)]
pub async fn members(ctx: Context<'_>) -> Result<()> {
let guild = ctx.guild().ok_or_else(|| eyre!("Couldn't fetch guild!"))?;
let guild = ctx.guild().ok_or_else(|| eyre!("Couldn't fetch guild!"))?;
let count = guild.member_count;
let online = if let Some(count) = guild.approximate_presence_count {
count.to_string()
} else {
"Undefined".to_string()
};
let count = guild.member_count;
let online = if let Some(count) = guild.approximate_presence_count {
count.to_string()
} else {
"Undefined".to_string()
};
ctx.send(|m| {
m.embed(|e| {
e.title(format!("{count} total members!"))
.description(format!("{online} online members"))
.color(consts::COLORS["blue"])
})
})
.await?;
Ok(())
ctx.send(|m| {
m.embed(|e| {
e.title(format!("{count} total members!"))
.description(format!("{online} online members"))
.color(consts::COLORS["blue"])
})
})
.await?;
Ok(())
}

View file

@ -5,6 +5,6 @@ use color_eyre::eyre::Result;
/// Replies with pong!
#[poise::command(slash_command, prefix_command, ephemeral)]
pub async fn ping(ctx: Context<'_>) -> Result<()> {
ctx.reply("Pong!").await?;
Ok(())
ctx.reply("Pong!").await?;
Ok(())
}

View file

@ -6,24 +6,24 @@ use color_eyre::eyre::Result;
/// Gets a Rory photo!
#[poise::command(slash_command, prefix_command)]
pub async fn rory(
ctx: Context<'_>,
#[description = "specify a Rory ID"] id: Option<u64>,
ctx: Context<'_>,
#[description = "specify a Rory ID"] id: Option<u64>,
) -> Result<()> {
let rory = get_rory(id).await?;
let rory = get_rory(id).await?;
ctx.send(|m| {
m.embed(|e| {
if let Some(error) = rory.error {
e.title("Error!").description(error)
} else {
e.title("Rory :3")
.url(&rory.url)
.image(rory.url)
.footer(|f| f.text(format!("ID {}", rory.id)))
}
})
})
.await?;
ctx.send(|m| {
m.embed(|e| {
if let Some(error) = rory.error {
e.title("Error!").description(error)
} else {
e.title("Rory :3")
.url(&rory.url)
.image(rory.url)
.footer(|f| f.text(format!("ID {}", rory.id)))
}
})
})
.await?;
Ok(())
Ok(())
}

View file

@ -4,48 +4,48 @@ use color_eyre::eyre::{eyre, Result};
/// Say something through the bot
#[poise::command(
slash_command,
prefix_command,
ephemeral,
default_member_permissions = "MODERATE_MEMBERS",
required_permissions = "MODERATE_MEMBERS"
slash_command,
prefix_command,
ephemeral,
default_member_permissions = "MODERATE_MEMBERS",
required_permissions = "MODERATE_MEMBERS"
)]
pub async fn say(ctx: Context<'_>, #[description = "Just content?"] content: String) -> Result<()> {
let guild = ctx.guild().ok_or_else(|| eyre!("Couldn't get guild!"))?;
let channel = ctx
.guild_channel()
.await
.ok_or_else(|| eyre!("Couldn't get channel!"))?;
let guild = ctx.guild().ok_or_else(|| eyre!("Couldn't get guild!"))?;
let channel = ctx
.guild_channel()
.await
.ok_or_else(|| eyre!("Couldn't get channel!"))?;
ctx.defer_ephemeral().await?;
channel.say(ctx, &content).await?;
ctx.say("I said what you said!").await?;
ctx.defer_ephemeral().await?;
channel.say(ctx, &content).await?;
ctx.say("I said what you said!").await?;
if let Some(channel_id) = ctx.data().config.discord.channels.say_log_channel_id {
let log_channel = guild
.channels
.iter()
.find(|c| c.0 == &channel_id)
.ok_or_else(|| eyre!("Couldn't get log channel from guild!"))?;
if let Some(channel_id) = ctx.data().config.discord.channels.say_log_channel_id {
let log_channel = guild
.channels
.iter()
.find(|c| c.0 == &channel_id)
.ok_or_else(|| eyre!("Couldn't get log channel from guild!"))?;
log_channel
.1
.clone()
.guild()
.ok_or_else(|| eyre!("Couldn't cast channel we found from guild as GuildChannel?????"))?
.send_message(ctx, |m| {
m.embed(|e| {
e.title("Say command used!")
.description(content)
.author(|a| {
a.name(ctx.author().tag()).icon_url(
ctx.author().avatar_url().unwrap_or("undefined".to_string()),
)
})
})
})
.await?;
}
log_channel
.1
.clone()
.guild()
.ok_or_else(|| eyre!("Couldn't cast channel we found from guild as GuildChannel?????"))?
.send_message(ctx, |m| {
m.embed(|e| {
e.title("Say command used!")
.description(content)
.author(|a| {
a.name(ctx.author().tag()).icon_url(
ctx.author().avatar_url().unwrap_or("undefined".to_string()),
)
})
})
})
.await?;
}
Ok(())
Ok(())
}

View file

@ -5,27 +5,27 @@ use color_eyre::eyre::{Context as _, Result};
/// Returns GitHub stargazer count
#[poise::command(slash_command, prefix_command)]
pub async fn stars(ctx: Context<'_>) -> Result<()> {
let prismlauncher = ctx
.data()
.octocrab
.repos("PrismLauncher", "PrismLauncher")
.get()
.await
.wrap_err_with(|| "Couldn't get PrismLauncher/PrismLauncher from GitHub!")?;
let prismlauncher = ctx
.data()
.octocrab
.repos("PrismLauncher", "PrismLauncher")
.get()
.await
.wrap_err_with(|| "Couldn't get PrismLauncher/PrismLauncher from GitHub!")?;
let count = if let Some(count) = prismlauncher.stargazers_count {
count.to_string()
} else {
"undefined".to_string()
};
let count = if let Some(count) = prismlauncher.stargazers_count {
count.to_string()
} else {
"undefined".to_string()
};
ctx.send(|m| {
m.embed(|e| {
e.title(format!("{count} total stars!"))
.color(COLORS["yellow"])
})
})
.await?;
ctx.send(|m| {
m.embed(|e| {
e.title(format!("{count} total stars!"))
.color(COLORS["yellow"])
})
})
.await?;
Ok(())
Ok(())
}

View file

@ -13,48 +13,48 @@ static TAGS: Lazy<Vec<Tag>> = Lazy::new(|| serde_json::from_str(env!("TAGS")).un
/// Send a tag
#[poise::command(slash_command, prefix_command)]
pub async fn tag(
ctx: Context<'_>,
#[description = "the copypasta you want to send"] name: TagChoice,
user: Option<User>,
ctx: Context<'_>,
#[description = "the copypasta you want to send"] name: TagChoice,
user: Option<User>,
) -> Result<()> {
let tag_file = name.as_str();
let tag = TAGS
.iter()
.find(|t| t.file_name == tag_file)
.ok_or_else(|| eyre!("Tried to get non-existent tag: {tag_file}"))?;
let tag_file = name.as_str();
let tag = TAGS
.iter()
.find(|t| t.file_name == tag_file)
.ok_or_else(|| eyre!("Tried to get non-existent tag: {tag_file}"))?;
let frontmatter = &tag.frontmatter;
let frontmatter = &tag.frontmatter;
ctx.send(|m| {
if let Some(user) = user {
m.content(format!("<@{}>", user.id));
}
ctx.send(|m| {
if let Some(user) = user {
m.content(format!("<@{}>", user.id));
}
m.embed(|e| {
e.title(&frontmatter.title);
e.description(&tag.content);
m.embed(|e| {
e.title(&frontmatter.title);
e.description(&tag.content);
if let Some(color) = &frontmatter.color {
let color = *consts::COLORS
.get(color.as_str())
.unwrap_or(&Color::default());
e.color(color);
}
if let Some(color) = &frontmatter.color {
let color = *consts::COLORS
.get(color.as_str())
.unwrap_or(&Color::default());
e.color(color);
}
if let Some(image) = &frontmatter.image {
e.image(image);
}
if let Some(image) = &frontmatter.image {
e.image(image);
}
if let Some(fields) = &frontmatter.fields {
for field in fields {
e.field(&field.name, &field.value, field.inline);
}
}
if let Some(fields) = &frontmatter.fields {
for field in fields {
e.field(&field.name, &field.value, field.inline);
}
}
e
})
})
.await?;
e
})
})
.await?;
Ok(())
Ok(())
}

View file

@ -6,13 +6,13 @@ use poise::Command;
mod general;
pub fn to_global_commands() -> Vec<Command<Data, Report>> {
vec![
general::joke(),
general::members(),
general::ping(),
general::rory(),
general::say(),
general::stars(),
general::tag(),
]
vec![
general::joke(),
general::members(),
general::ping(),
general::rory(),
general::say(),
general::stars(),
general::tag(),
]
}