forked from Skynet/discord-bot
feat: made the minecraft command fall under Wolves
This commit is contained in:
parent
df032f2d7b
commit
f307fcea43
4 changed files with 26 additions and 22 deletions
|
@ -23,4 +23,4 @@ You will get member roles on any Discord that is using the bot that you are a me
|
|||
### Minecraft
|
||||
You can link your Minecraft username to grant you access to any Minecraft server run by UL Computer Society.
|
||||
|
||||
``/link_minecraft MINECRAFT_USERNAME``
|
||||
``/wolves link_minecraft MINECRAFT_USERNAME``
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use serenity::{builder::CreateCommand, client::Context};
|
||||
use serenity::client::Context;
|
||||
|
||||
use skynet_discord_bot::common::database::DataBase;
|
||||
use sqlx::{Pool, Sqlite};
|
||||
|
@ -9,20 +9,13 @@ pub(crate) mod user {
|
|||
use super::*;
|
||||
use crate::commands::wolves::link::get_server_member_discord;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction, CommandOptionType, CreateCommandOption};
|
||||
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction};
|
||||
use serenity::model::id::UserId;
|
||||
use skynet_discord_bot::common::database::Wolves;
|
||||
use skynet_discord_bot::common::minecraft::{whitelist_update, Minecraft};
|
||||
use skynet_discord_bot::Config;
|
||||
use sqlx::Error;
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("link_minecraft")
|
||||
.description("Link your minecraft account")
|
||||
.add_option(CreateCommandOption::new(CommandOptionType::String, "minecraft_username", "Your Minecraft username").required(true))
|
||||
.add_option(CreateCommandOption::new(CommandOptionType::Boolean, "bedrock_account", "Is this a Bedrock account?").required(false))
|
||||
}
|
||||
|
||||
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
||||
let db_lock = {
|
||||
let data_read = ctx.data.read().await;
|
||||
|
@ -41,23 +34,30 @@ pub(crate) mod user {
|
|||
return "Not linked with wolves, please use ``/link_wolves`` with your wolves email.".to_string();
|
||||
}
|
||||
|
||||
let username = if let Some(CommandDataOption {
|
||||
value: CommandDataOptionValue::String(username),
|
||||
let sub_options = if let Some(CommandDataOption {
|
||||
value: CommandDataOptionValue::SubCommand(options),
|
||||
..
|
||||
}) = command.data.options.first()
|
||||
{
|
||||
username.trim()
|
||||
options
|
||||
} else {
|
||||
return "Please provide sub options".to_string();
|
||||
};
|
||||
|
||||
let username = if let Some(x) = sub_options.first() {
|
||||
match &x.value {
|
||||
CommandDataOptionValue::String(username) => username.trim(),
|
||||
_ => return "Please provide a valid username".to_string(),
|
||||
}
|
||||
} else {
|
||||
return "Please provide a valid username".to_string();
|
||||
};
|
||||
|
||||
// this is always true unless they state its not
|
||||
let java = if let Some(CommandDataOption {
|
||||
value: CommandDataOptionValue::Boolean(z),
|
||||
..
|
||||
}) = command.data.options.get(1)
|
||||
{
|
||||
!z
|
||||
let java = if let Some(x) = sub_options.get(1) {
|
||||
match &x.value {
|
||||
CommandDataOptionValue::Boolean(z) => !z,
|
||||
_ => true,
|
||||
}
|
||||
} else {
|
||||
true
|
||||
};
|
||||
|
|
|
@ -511,4 +511,9 @@ pub fn register() -> CreateCommand {
|
|||
)
|
||||
// unlink
|
||||
.add_option(CreateCommandOption::new(CommandOptionType::SubCommand, "unlink", "Unlink your Wolves account from your Discord"))
|
||||
.add_option(
|
||||
CreateCommandOption::new(CommandOptionType::SubCommand, "link_minecraft", "Link your minecraft account")
|
||||
.add_sub_option(CreateCommandOption::new(CommandOptionType::String, "minecraft_username", "Your Minecraft username").required(true))
|
||||
.add_sub_option(CreateCommandOption::new(CommandOptionType::Boolean, "bedrock_account", "Is this a Bedrock account?").required(false)),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -118,7 +118,6 @@ Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use
|
|||
commands::minecraft::server::add::register(),
|
||||
commands::minecraft::server::list::register(),
|
||||
commands::minecraft::server::delete::register(),
|
||||
commands::minecraft::user::add::register(),
|
||||
],
|
||||
)
|
||||
.await
|
||||
|
@ -170,12 +169,12 @@ Sign up on [UL Wolves]({}) and go to https://discord.com/channels/{}/{} and use
|
|||
"link" => commands::wolves::link::run(&command, &ctx).await,
|
||||
"verify" => commands::wolves::verify::run(&command, &ctx).await,
|
||||
"unlink" => commands::wolves::unlink::run(&command, &ctx).await,
|
||||
"link_minecraft" => commands::minecraft::user::add::run(&command, &ctx).await,
|
||||
// "link" => commands::count::servers::run(&command, &ctx).await,
|
||||
&_ => format!("not implemented :( wolves {}", x.name.as_str()),
|
||||
},
|
||||
},
|
||||
|
||||
"link_minecraft" => commands::minecraft::user::add::run(&command, &ctx).await,
|
||||
// admin commands
|
||||
"committee" => match command.data.options.first() {
|
||||
None => "Invalid Command".to_string(),
|
||||
|
|
Loading…
Add table
Reference in a new issue