Remove macros

This commit is contained in:
oupson1er@gmail.com 2021-03-17 23:49:36 +01:00
parent 130be477d0
commit 5ac371acb1
3 changed files with 8 additions and 17 deletions

View File

@ -1,4 +1,3 @@
use crate::debugln;
use serenity::{ use serenity::{
framework::standard::{ framework::standard::{
macros::{command, group}, macros::{command, group},
@ -7,6 +6,7 @@ use serenity::{
model::prelude::*, model::prelude::*,
prelude::*, prelude::*,
}; };
use log::debug;
use std::convert::TryFrom; use std::convert::TryFrom;
#[group] #[group]
@ -26,7 +26,7 @@ pub async fn leave_guild(ctx: &Context, _msg: &Message, mut args: Args) -> Comma
async fn send_message(ctx: &Context, _msg: &Message, mut args: Args) -> CommandResult { async fn send_message(ctx: &Context, _msg: &Message, mut args: Args) -> CommandResult {
let channel_id = args.single::<ChannelId>()?; let channel_id = args.single::<ChannelId>()?;
let message = args.single::<String>()?; let message = args.single::<String>()?;
debugln!("Send {} into {:?}", message, channel_id); debug!("Send {} into {:?}", message, channel_id);
channel_id.say(ctx, message).await?; channel_id.say(ctx, message).await?;
Ok(()) Ok(())
} }

View File

@ -1,8 +0,0 @@
#[macro_export]
macro_rules! debugln {
($($arg:tt)*) => {
if cfg!(debug_assertions) {
log::debug!($($arg)*);
}
};
}

View File

@ -38,7 +38,6 @@ mod api;
mod commands; mod commands;
mod config; mod config;
mod data; mod data;
mod macros;
mod presence; mod presence;
const PREFIX: &str = "?"; const PREFIX: &str = "?";
@ -49,8 +48,8 @@ pub(crate) static mut INVITE_URL: Option<String> = None;
#[tokio::main] #[tokio::main]
async fn main() -> IoResult<()> { async fn main() -> IoResult<()> {
log4rs::init_file("log4rs.yaml", Default::default()).unwrap(); log4rs::init_file("log4rs.yaml", Default::default()).unwrap();
let conf: config::Conf = toml::from_str(&std::fs::read_to_string("Conf.toml")?)?; let conf: config::Conf = toml::from_str(&fs::read_to_string("Conf.toml")?)?;
debugln!("conf : {:?}", conf); debug!("conf : {:?}", conf);
let token = conf.bot.token; let token = conf.bot.token;
@ -66,7 +65,7 @@ async fn main() -> IoResult<()> {
} }
} }
debugln!("Log attachments : {}", unsafe { LOG_ATTACHMENTS }); debug!("Log attachments : {}", unsafe { LOG_ATTACHMENTS });
let dir = Path::new("logging"); let dir = Path::new("logging");
if !dir.exists() { if !dir.exists() {
@ -91,7 +90,7 @@ async fn main() -> IoResult<()> {
Err(why) => panic!("Could not access application info: {:?}", why), Err(why) => panic!("Could not access application info: {:?}", why),
}; };
debugln!("Owners : {:?}", owners); debug!("Owners : {:?}", owners);
let mut framework = StandardFramework::new() let mut framework = StandardFramework::new()
.configure(|c| { .configure(|c| {
@ -262,7 +261,7 @@ impl EventHandler for Messages {
} }
async fn download_to_log(attachment: Attachment) -> commands::Result<()> { async fn download_to_log(attachment: Attachment) -> commands::Result<()> {
debugln!("Download_to_log : {:?}", attachment); debug!("Download_to_log : {:?}", attachment);
let path = Path::new("logging").join(format!("{}-{}", attachment.id, attachment.filename)); let path = Path::new("logging").join(format!("{}-{}", attachment.id, attachment.filename));
let content = reqwest::get(&attachment.url).await?.bytes().await?; let content = reqwest::get(&attachment.url).await?.bytes().await?;
let mut file = File::create(path).await?; let mut file = File::create(path).await?;
@ -282,7 +281,7 @@ async fn normal_message(_ctx: &Context, msg: &Message) {
#[hook] #[hook]
async fn dispatch_error(ctx: &Context, msg: &Message, error: DispatchError) { async fn dispatch_error(ctx: &Context, msg: &Message, error: DispatchError) {
debugln!("Dispatch error : {:?}", error); debug!("Dispatch error : {:?}", error);
match error { match error {
DispatchError::Ratelimited(seconds) => { DispatchError::Ratelimited(seconds) => {
let _ = msg let _ = msg