debug_say for crosspost
This commit is contained in:
parent
de5cd63e9c
commit
c62add05e6
2 changed files with 18 additions and 9 deletions
|
@ -1,6 +1,5 @@
|
||||||
use crate::util::debug_say;
|
use crate::util::debug_channel_say;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use log::error;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serenity::framework::standard::CommandError;
|
use serenity::framework::standard::CommandError;
|
||||||
use serenity::framework::standard::{macros::command, Args, CommandResult};
|
use serenity::framework::standard::{macros::command, Args, CommandResult};
|
||||||
|
@ -44,7 +43,7 @@ async fn crosspost(ctx: &Context, msg: &Message, mut args: Args) -> CommandResul
|
||||||
args.rest()
|
args.rest()
|
||||||
);
|
);
|
||||||
for channel in channels {
|
for channel in channels {
|
||||||
channel.say(ctx, &rest).await?;
|
debug_channel_say(&channel.into(), *msg.author.id.as_u64(), ctx, &rest).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use serenity::{http::Http, model::channel::Message};
|
use serenity::{
|
||||||
|
http::Http,
|
||||||
|
model::{channel::Message, id::ChannelId},
|
||||||
|
};
|
||||||
use std::env::var;
|
use std::env::var;
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
@ -24,12 +27,19 @@ pub async fn debug_say(
|
||||||
ctx: impl AsRef<Http>,
|
ctx: impl AsRef<Http>,
|
||||||
resp: impl std::fmt::Display,
|
resp: impl std::fmt::Display,
|
||||||
) -> Result<Option<Message>, serenity::Error> {
|
) -> Result<Option<Message>, serenity::Error> {
|
||||||
if cfg!(debug_assertions) && *msg.author.id.as_u64() == *BOT_OWNER_ID {
|
debug_channel_say(&msg.channel_id, *msg.author.id.as_u64(), ctx, resp).await
|
||||||
Ok(Some(
|
}
|
||||||
msg.channel_id.say(ctx, format!("DEBUG: {}", resp)).await?,
|
|
||||||
))
|
pub async fn debug_channel_say(
|
||||||
|
channel: &ChannelId,
|
||||||
|
author_id: u64,
|
||||||
|
ctx: impl AsRef<Http>,
|
||||||
|
resp: impl std::fmt::Display,
|
||||||
|
) -> Result<Option<Message>, serenity::Error> {
|
||||||
|
if cfg!(debug_assertions) && author_id == *BOT_OWNER_ID {
|
||||||
|
Ok(Some(channel.say(ctx, format!("DEBUG: {}", resp)).await?))
|
||||||
} else if !cfg!(debug_assertions) {
|
} else if !cfg!(debug_assertions) {
|
||||||
Ok(Some(msg.channel_id.say(ctx, resp).await?))
|
Ok(Some(channel.say(ctx, resp).await?))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue