This commit is contained in:
poslop
2022-12-05 15:43:53 -06:00
parent 16f9dd1c04
commit 7fc1c1eba3
2 changed files with 26 additions and 18 deletions

View File

@@ -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

View File

@@ -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::<TcpSock>().unwrap();
let conf = data.get::<Config>().unwrap();
// let conf = data.get::<Config>().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()
}
// async fn check_role(ctx: &Context, msg: &Message, conf: &Config) -> Result<bool, SerenityError> {
// 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)
// }