better api for debug_channel_say

This commit is contained in:
Edward Shen 2020-05-02 15:58:11 -04:00
parent c62add05e6
commit 144564f4f7
Signed by: edward
GPG key ID: 19182661E818369F
2 changed files with 5 additions and 4 deletions

View file

@ -43,7 +43,7 @@ async fn crosspost(ctx: &Context, msg: &Message, mut args: Args) -> CommandResul
args.rest()
);
for channel in channels {
debug_channel_say(&channel.into(), *msg.author.id.as_u64(), ctx, &rest).await?;
debug_channel_say(channel, msg.author.id, ctx, &rest).await?;
}
Ok(())

View file

@ -31,12 +31,13 @@ pub async fn debug_say(
}
pub async fn debug_channel_say(
channel: &ChannelId,
author_id: u64,
channel: impl Into<ChannelId>,
author_id: impl Into<u64>,
ctx: impl AsRef<Http>,
resp: impl std::fmt::Display,
) -> Result<Option<Message>, serenity::Error> {
if cfg!(debug_assertions) && author_id == *BOT_OWNER_ID {
let channel: ChannelId = channel.into();
if cfg!(debug_assertions) && author_id.into() == *BOT_OWNER_ID {
Ok(Some(channel.say(ctx, format!("DEBUG: {}", resp)).await?))
} else if !cfg!(debug_assertions) {
Ok(Some(channel.say(ctx, resp).await?))