initial rewrite in rust & moderation commands
Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
parent
b17e357b75
commit
45403e9d9b
53 changed files with 3297 additions and 2820 deletions
12
src/commands/general/joke.rs
Normal file
12
src/commands/general/joke.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use crate::api::dadjoke;
|
||||
use crate::Context;
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
|
||||
#[poise::command(slash_command, prefix_command)]
|
||||
pub async fn joke(ctx: Context<'_>) -> Result<()> {
|
||||
let joke = dadjoke::get_joke().await?;
|
||||
|
||||
ctx.reply(joke).await?;
|
||||
Ok(())
|
||||
}
|
25
src/commands/general/members.rs
Normal file
25
src/commands/general/members.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use crate::{consts, Context};
|
||||
|
||||
use color_eyre::eyre::{eyre, Result};
|
||||
|
||||
#[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 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(())
|
||||
}
|
13
src/commands/general/mod.rs
Normal file
13
src/commands/general/mod.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
mod joke;
|
||||
mod members;
|
||||
mod modrinth;
|
||||
mod rory;
|
||||
mod say;
|
||||
mod stars;
|
||||
|
||||
pub use joke::joke;
|
||||
pub use members::members;
|
||||
pub use modrinth::modrinth;
|
||||
pub use rory::rory;
|
||||
pub use say::say;
|
||||
pub use stars::stars;
|
8
src/commands/general/modrinth.rs
Normal file
8
src/commands/general/modrinth.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
use crate::Context;
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
|
||||
#[poise::command(slash_command, prefix_command)]
|
||||
pub async fn modrinth(ctx: Context<'_>) -> Result<()> {
|
||||
todo!()
|
||||
}
|
21
src/commands/general/rory.rs
Normal file
21
src/commands/general/rory.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use crate::api::rory::get_rory;
|
||||
use crate::Context;
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
|
||||
#[poise::command(slash_command, prefix_command)]
|
||||
pub async fn rory(ctx: Context<'_>, id: Option<u64>) -> Result<()> {
|
||||
let resp = get_rory(id).await?;
|
||||
|
||||
ctx.send(|m| {
|
||||
m.embed(|e| {
|
||||
e.title("Rory :3")
|
||||
.url(&resp.url)
|
||||
.image(resp.url)
|
||||
.footer(|f| f.text(format!("ID {}", resp.id)))
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
43
src/commands/general/say.rs
Normal file
43
src/commands/general/say.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
use crate::Context;
|
||||
|
||||
use color_eyre::eyre::{eyre, Result};
|
||||
|
||||
#[poise::command(slash_command, prefix_command, ephemeral)]
|
||||
pub async fn say(ctx: Context<'_>, 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!"))?;
|
||||
|
||||
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!"))?;
|
||||
|
||||
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(())
|
||||
}
|
30
src/commands/general/stars.rs
Normal file
30
src/commands/general/stars.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use crate::{consts::COLORS, Context};
|
||||
|
||||
use color_eyre::eyre::{Context as _, Result};
|
||||
|
||||
#[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 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?;
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue