log more actions + tidy up things

This commit is contained in:
seth 2024-03-03 18:32:44 -05:00
parent 651f14d724
commit 915ef54dc3
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
14 changed files with 56 additions and 19 deletions

View file

@ -2,10 +2,12 @@ use crate::api::dadjoke;
use crate::Context;
use eyre::Result;
use log::trace;
/// It's a joke
#[poise::command(slash_command, prefix_command)]
pub async fn joke(ctx: Context<'_>) -> Result<()> {
trace!("Running joke command");
let joke = dadjoke::get_joke().await?;
ctx.reply(joke).await?;

View file

@ -1,12 +1,14 @@
use crate::{consts, Context};
use eyre::{OptionExt, Result};
use log::trace;
use poise::serenity_prelude::CreateEmbed;
use poise::CreateReply;
/// Returns the number of members in the server
#[poise::command(slash_command, prefix_command)]
pub async fn members(ctx: Context<'_>) -> Result<()> {
trace!("Running members command");
let guild = ctx.guild().ok_or_eyre("Couldn't fetch guild!")?.to_owned();
let count = guild.member_count;

View file

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

View file

@ -2,6 +2,7 @@ use crate::api::rory;
use crate::Context;
use eyre::Result;
use log::trace;
use poise::serenity_prelude::{CreateEmbed, CreateEmbedFooter};
use poise::CreateReply;
@ -11,6 +12,7 @@ pub async fn rory(
ctx: Context<'_>,
#[description = "specify a Rory ID"] id: Option<u64>,
) -> Result<()> {
trace!("Running rory command");
let rory = rory::get(id).await?;
let embed = {

View file

@ -22,7 +22,7 @@ pub async fn say(ctx: Context<'_>, #[description = "Just content?"] content: Str
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 {
if let Some(channel_id) = ctx.data().config.discord.channels().say_log_channel_id() {
let log_channel = guild
.channels
.iter()

View file

@ -1,12 +1,15 @@
use crate::{consts, Context};
use eyre::{Context as _, Result};
use log::trace;
use poise::serenity_prelude::CreateEmbed;
use poise::CreateReply;
/// Returns GitHub stargazer count
#[poise::command(slash_command, prefix_command)]
pub async fn stars(ctx: Context<'_>) -> Result<()> {
trace!("Running stars command");
let prismlauncher = ctx
.data()
.octocrab

View file

@ -3,7 +3,8 @@ use crate::tags::Tag;
use crate::{consts, Context};
use std::env;
use eyre::{OptionExt, Result};
use eyre::{eyre, Result};
use log::trace;
use once_cell::sync::Lazy;
use poise::serenity_prelude::{Color, CreateEmbed, User};
use poise::CreateReply;
@ -18,11 +19,13 @@ pub async fn tag(
#[description = "the copypasta you want to send"] name: Choice,
user: Option<User>,
) -> Result<()> {
trace!("Running tag command");
let tag_file = name.as_str();
let tag = TAGS
.iter()
.find(|t| t.file_name == tag_file)
.ok_or_eyre("Tried to get non-existent tag: {tag_file}")?;
.ok_or_else(|| eyre!("Tried to get non-existent tag: {tag_file}"))?;
let frontmatter = &tag.frontmatter;