say: use channel_id, only use prefix command
This commit is contained in:
parent
59bf42998b
commit
a41a84fd2d
1 changed files with 4 additions and 18 deletions
|
@ -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?;
|
||||||
|
|
||||||
if let Context::Application(_) = ctx {
|
|
||||||
ctx.say("I said what you said!").await?;
|
ctx.say("I said what you said!").await?;
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(channel_id) = ctx
|
if let Some(channel_id) = ctx
|
||||||
.data()
|
.data()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue