From 7fc1c1eba34133bf072816f29fa57c72dfeb1556 Mon Sep 17 00:00:00 2001 From: poslop Date: Mon, 5 Dec 2022 15:43:53 -0600 Subject: [PATCH] up --- readme.md | 10 +++++++--- src/main.rs | 34 +++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/readme.md b/readme.md index e3c2a7d..12fa7c1 100644 --- a/readme.md +++ b/readme.md @@ -15,15 +15,19 @@ The available options are: - discordToken = the discord bot token (required) - ip = Ip address of your mindustry server. Usually leave as localhost if running the bot on the same machine as the mindustry server (required) - port = Port of the socket used by the mindustry server. It is set to the default port used by the mindustry server but you can check which port is in use by useing the "config socketInputPort" command in the server console (required) -- trigger = The single letter or character that will be used to call the bot (ex. ;command !command ?command mcommand) (optional) -- roles = Not currently implemented (optional) +- prefix = The word or character that will be used to call the bot (ex. ;command !command ?command MScommand) (optional) +- roles = unimplemented ## Commands ; is currently the default bot prompt - ;console (command to send to mindustry server console) -(parenthesis not needed for console command) +- ;git (post git link) + +- ;discord (post discord link) + +(parenthesis not needed) ## Todo diff --git a/src/main.rs b/src/main.rs index 22711bf..0be4f61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,8 @@ use serenity::framework::standard::macros::{command, group, help, hook}; use serenity::framework::standard::{StandardFramework, CommandResult, Args, HelpOptions, CommandGroup, help_commands}; use serenity::utils::Color; use std::collections::HashSet; +use std::error::Error; +use std::io::Stderr; use std::str::FromStr; #[group] @@ -115,19 +117,19 @@ async fn console(ctx: &Context, msg: &Message) -> CommandResult { let data = ctx.data.read().await; let sock = data.get::().unwrap(); - let conf = data.get::().unwrap(); + // let conf = data.get::().unwrap(); - if !check_role(ctx, msg, conf).await { - // msg.channel_id.say(ctx, "You do not have permission to use this command").await?; - msg.channel_id.send_message(ctx, |m| { - m.content("test") - .embed(|e| e - .title("No Permissions") - .description("You do not have permission to use this command") - .color(Color::RED)) - }).await?; - return Ok(()); - } + // if !check_role(ctx, msg, conf).await.unwrap_or_else(|e| false) { + // // msg.channel_id.say(ctx, "You do not have permission to use this command").await?; + // msg.channel_id.send_message(ctx, |m| { + // m.content("test") + // .embed(|e| e + // .title("No Permissions") + // .description("You do not have permission to use this command") + // .color(Color::RED)) + // }).await?; + // return Ok(()); + // } msg.reply(ctx, format!("```\n{}\n```", cons_rw(sock, &input.unwrap()))).await?; Ok(()) @@ -145,6 +147,8 @@ async fn discord(ctx: &Context, msg: &Message) -> CommandResult { Ok(()) } -async fn check_role(ctx: &Context, msg: &Message, conf: &Config) -> bool { - msg.author.has_role(ctx, msg.guild_id.unwrap(), RoleId::from(u64::from_str(&conf.roles.cons).unwrap())).await.unwrap() -} \ No newline at end of file +// async fn check_role(ctx: &Context, msg: &Message, conf: &Config) -> Result { +// let id = RoleId::from(u64::from_str(&conf.roles.cons))?; +// let check = msg.author.has_role(ctx, msg.guild_id.unwrap(), id).await?; +// Ok(check) +// } \ No newline at end of file