forked from Skynet/discord-bot
feat: change commands to use the "Manage Server" permission instead of just admin.
This measn that the commands only show up if you can manage teh server
This commit is contained in:
parent
09ce45f70f
commit
7406f0e620
4 changed files with 21 additions and 73 deletions
|
@ -192,19 +192,19 @@ pub(crate) mod server {
|
|||
use super::*;
|
||||
use skynet_discord_bot::common::minecraft::update_server;
|
||||
use skynet_discord_bot::common::minecraft::Minecraft;
|
||||
use skynet_discord_bot::{is_admin, Config};
|
||||
use skynet_discord_bot::Config;
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("minecraft_add").description("Add a minecraft server").add_option(
|
||||
CreateCommandOption::new(CommandOptionType::String, "server_id", "ID of the Minecraft server hosted by the Computer Society").required(true),
|
||||
)
|
||||
CreateCommand::new("minecraft_add")
|
||||
.description("Add a minecraft server")
|
||||
.default_member_permissions(serenity::model::Permissions::MANAGE_GUILD)
|
||||
.add_option(
|
||||
CreateCommandOption::new(CommandOptionType::String, "server_id", "ID of the Minecraft server hosted by the Computer Society")
|
||||
.required(true),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
||||
// check if user has high enough permisssions
|
||||
if let Some(msg) = is_admin(command, ctx).await {
|
||||
return msg;
|
||||
}
|
||||
let g_id = match command.guild_id {
|
||||
None => return "Not in a server".to_string(),
|
||||
Some(x) => x,
|
||||
|
@ -265,16 +265,15 @@ pub(crate) mod server {
|
|||
use serenity::client::Context;
|
||||
use skynet_discord_bot::common::database::DataBase;
|
||||
use skynet_discord_bot::common::minecraft::{get_minecraft_config_server, server_information};
|
||||
use skynet_discord_bot::{is_admin, Config};
|
||||
use skynet_discord_bot::Config;
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("minecraft_list").description("List your minecraft servers")
|
||||
CreateCommand::new("minecraft_list")
|
||||
.default_member_permissions(serenity::model::Permissions::MANAGE_GUILD)
|
||||
.description("List your minecraft servers")
|
||||
}
|
||||
|
||||
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
||||
if let Some(msg) = is_admin(command, ctx).await {
|
||||
return msg;
|
||||
}
|
||||
let g_id = match command.guild_id {
|
||||
None => return "Not in a server".to_string(),
|
||||
Some(x) => x,
|
||||
|
@ -327,20 +326,19 @@ pub(crate) mod server {
|
|||
use serenity::model::id::GuildId;
|
||||
use skynet_discord_bot::common::database::DataBase;
|
||||
use skynet_discord_bot::common::minecraft::Minecraft;
|
||||
use skynet_discord_bot::is_admin;
|
||||
use sqlx::{Error, Pool, Sqlite};
|
||||
|
||||
pub fn register() -> CreateCommand {
|
||||
CreateCommand::new("minecraft_delete").description("Delete a minecraft server").add_option(
|
||||
CreateCommandOption::new(CommandOptionType::String, "server_id", "ID of the Minecraft server hosted by the Computer Society").required(true),
|
||||
)
|
||||
CreateCommand::new("minecraft_delete")
|
||||
.description("Delete a minecraft server")
|
||||
.default_member_permissions(serenity::model::Permissions::MANAGE_GUILD)
|
||||
.add_option(
|
||||
CreateCommandOption::new(CommandOptionType::String, "server_id", "ID of the Minecraft server hosted by the Computer Society")
|
||||
.required(true),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
|
||||
// check if user has high enough permisssions
|
||||
if let Some(msg) = is_admin(command, ctx).await {
|
||||
return msg;
|
||||
}
|
||||
let g_id = match command.guild_id {
|
||||
None => return "Not in a server".to_string(),
|
||||
Some(x) => x,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue