feat: add /set_welcome command

This commit is contained in:
seth 2024-03-29 17:54:53 -04:00
parent 239928a22a
commit 59bf42998b
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
7 changed files with 286 additions and 51 deletions

View file

@ -1,8 +1,8 @@
use crate::Context;
use crate::{utils, Context};
use eyre::{OptionExt, Result};
use log::trace;
use poise::serenity_prelude::{CreateEmbed, CreateEmbedAuthor, CreateMessage};
use poise::serenity_prelude::{CreateEmbed, CreateMessage};
/// Say something through the bot
#[poise::command(
@ -17,7 +17,6 @@ pub async fn say(
ctx: Context<'_>,
#[description = "the message content"] content: String,
) -> Result<()> {
let guild = ctx.guild().ok_or_eyre("Couldn't get guild!")?.to_owned();
let channel = ctx
.guild_channel()
.await
@ -41,19 +40,9 @@ pub async fn say(
.clone()
.discord_config()
.channels()
.say_log_channel_id()
.log_channel_id()
{
let log_channel = guild
.channels
.iter()
.find(|c| c.0 == &channel_id)
.ok_or_eyre("Couldn't get log channel from guild!")?;
let author = CreateEmbedAuthor::new(ctx.author().tag()).icon_url(
ctx.author()
.avatar_url()
.unwrap_or_else(|| ctx.author().default_avatar_url()),
);
let author = utils::embed_author_from_user(ctx.author());
let embed = CreateEmbed::default()
.title("Say command used!")
@ -61,7 +50,7 @@ pub async fn say(
.author(author);
let message = CreateMessage::new().embed(embed);
log_channel.1.send_message(ctx, message).await?;
channel_id.send_message(ctx, message).await?;
} else {
trace!("Not sending /say log as no channel is set");
}