say: use channel_id, only use prefix command

This commit is contained in:
seth 2024-03-29 18:00:30 -04:00
parent 59bf42998b
commit a41a84fd2d
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86

View file

@ -1,38 +1,24 @@
use crate::{utils, Context}; use crate::{utils, Context};
use eyre::{OptionExt, Result}; use eyre::Result;
use log::trace; use log::trace;
use poise::serenity_prelude::{CreateEmbed, CreateMessage}; use poise::serenity_prelude::{CreateEmbed, CreateMessage};
/// Say something through the bot /// Say something through the bot
#[poise::command( #[poise::command(
slash_command, slash_command,
prefix_command,
ephemeral, ephemeral,
default_member_permissions = "MODERATE_MEMBERS", default_member_permissions = "MODERATE_MEMBERS",
required_permissions = "MODERATE_MEMBERS", required_permissions = "MODERATE_MEMBERS",
guild_only = true guild_only
)] )]
pub async fn say( pub async fn say(
ctx: Context<'_>, ctx: Context<'_>,
#[description = "the message content"] content: String, #[description = "the message content"] content: String,
) -> Result<()> { ) -> Result<()> {
let channel = ctx let channel = ctx.channel_id();
.guild_channel()
.await
.ok_or_eyre("Couldn't get channel!")?;
if let Context::Prefix(prefix) = ctx {
// ignore error, we might not have perm
let _ = prefix.msg.delete(ctx).await;
}
ctx.defer_ephemeral().await?;
channel.say(ctx, &content).await?; channel.say(ctx, &content).await?;
ctx.say("I said what you said!").await?;
if let Context::Application(_) = ctx {
ctx.say("I said what you said!").await?;
}
if let Some(channel_id) = ctx if let Some(channel_id) = ctx
.data() .data()