Fix slash command permission
This commit is contained in:
parent
53417bd700
commit
c36a4c9b80
@ -1,6 +1,7 @@
|
|||||||
package net.Broken;
|
package net.Broken;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||||
|
|
||||||
@ -34,7 +35,5 @@ public interface SlashCommand {
|
|||||||
|
|
||||||
boolean isPrivateUsable();
|
boolean isPrivateUsable();
|
||||||
|
|
||||||
|
DefaultMemberPermissions getDefaultPermissions();
|
||||||
boolean isDisableByDefault();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
|
|
||||||
import net.Broken.SlashCommand;
|
import net.Broken.SlashCommand;
|
||||||
import net.Broken.Tools.EmbedMessageUtils;
|
import net.Broken.Tools.EmbedMessageUtils;
|
||||||
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||||
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||||
@ -94,7 +96,8 @@ public class Cat implements SlashCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisableByDefault() {
|
public DefaultMemberPermissions getDefaultPermissions(){
|
||||||
return false;
|
return DefaultMemberPermissions.enabledFor(Permission.MESSAGE_SEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import net.Broken.Tools.EmbedMessageUtils;
|
|||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||||
@ -63,7 +64,9 @@ public class Clear implements SlashCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisableByDefault() {
|
public DefaultMemberPermissions getDefaultPermissions() {
|
||||||
return true;
|
return DefaultMemberPermissions.enabledFor(Permission.MESSAGE_MANAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import net.Broken.Audio.GuildAudioBotService;
|
|||||||
import net.Broken.Tools.EmbedMessageUtils;
|
import net.Broken.Tools.EmbedMessageUtils;
|
||||||
import net.dv8tion.jda.api.entities.channel.unions.AudioChannelUnion;
|
import net.dv8tion.jda.api.entities.channel.unions.AudioChannelUnion;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
@ -139,7 +140,9 @@ public class Music implements SlashCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisableByDefault() {
|
public DefaultMemberPermissions getDefaultPermissions() {
|
||||||
return false;
|
return DefaultMemberPermissions.ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package net.Broken.SlashCommands.Over18;
|
|||||||
import net.Broken.Tools.Command.Ignore;
|
import net.Broken.Tools.Command.Ignore;
|
||||||
import net.Broken.Tools.Command.NoDev;
|
import net.Broken.Tools.Command.NoDev;
|
||||||
import net.Broken.Tools.Command.NumberedSlashCommand;
|
import net.Broken.Tools.Command.NumberedSlashCommand;
|
||||||
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
@NoDev
|
@NoDev
|
||||||
@ -35,7 +38,7 @@ public class Ass extends NumberedSlashCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisableByDefault() {
|
public DefaultMemberPermissions getDefaultPermissions() {
|
||||||
return true;
|
return DefaultMemberPermissions.enabledFor(Permission.MESSAGE_SEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,10 @@ package net.Broken.SlashCommands.Over18;
|
|||||||
import net.Broken.Tools.Command.Ignore;
|
import net.Broken.Tools.Command.Ignore;
|
||||||
import net.Broken.Tools.Command.NoDev;
|
import net.Broken.Tools.Command.NoDev;
|
||||||
import net.Broken.Tools.Command.NumberedSlashCommand;
|
import net.Broken.Tools.Command.NumberedSlashCommand;
|
||||||
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@ -37,7 +41,7 @@ public class Boobs extends NumberedSlashCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisableByDefault() {
|
public DefaultMemberPermissions getDefaultPermissions() {
|
||||||
return true;
|
return DefaultMemberPermissions.enabledFor(Permission.MESSAGE_SEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package net.Broken.SlashCommands.Over18;
|
|||||||
|
|
||||||
import net.Broken.Tools.Command.NoDev;
|
import net.Broken.Tools.Command.NoDev;
|
||||||
import net.Broken.Tools.Command.NumberedSlashCommand;
|
import net.Broken.Tools.Command.NumberedSlashCommand;
|
||||||
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
import net.Broken.Tools.FindContentOnWebPage;
|
import net.Broken.Tools.FindContentOnWebPage;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@ -57,11 +59,11 @@ public class Madame extends NumberedSlashCommand {
|
|||||||
int randomResult = randomQueue.poll();
|
int randomResult = randomQueue.poll();
|
||||||
String url = baseURL + randomResult + urlSuffix;
|
String url = baseURL + randomResult + urlSuffix;
|
||||||
|
|
||||||
logger.debug("URL: " + url);
|
logger.debug("URL: {}",url);
|
||||||
|
|
||||||
|
|
||||||
if (scanPageForTipeee(url, logger)) {
|
if (scanPageForTipeee(url, logger)) {
|
||||||
logger.debug("Advertisement detected! Retry! (" + url + ")");
|
logger.debug("Advertisement detected! Retry! ({})", url);
|
||||||
} else {
|
} else {
|
||||||
imgUrl = FindContentOnWebPage.doYourJob(url, "post-content", "img");
|
imgUrl = FindContentOnWebPage.doYourJob(url, "post-content", "img");
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ public class Madame extends NumberedSlashCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisableByDefault() {
|
public DefaultMemberPermissions getDefaultPermissions() {
|
||||||
return true;
|
return DefaultMemberPermissions.enabledFor(Permission.MESSAGE_SEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import net.Broken.SpringContext;
|
|||||||
import net.Broken.Tools.UserManager.Stats.UserStatsUtils;
|
import net.Broken.Tools.UserManager.Stats.UserStatsUtils;
|
||||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||||
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
import net.dv8tion.jda.api.interactions.components.buttons.Button;
|
||||||
@ -56,7 +57,7 @@ public class Rank implements SlashCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisableByDefault() {
|
public DefaultMemberPermissions getDefaultPermissions() {
|
||||||
return false;
|
return DefaultMemberPermissions.ENABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class CommandParser {
|
|||||||
args[i] = args[i].replace('$', ' ');
|
args[i] = args[i].replace('$', ' ');
|
||||||
|
|
||||||
|
|
||||||
logger.info("Author: " + e.getAuthor().getName() + ", Command: " + commande + ", args: " + Arrays.toString(args));
|
logger.info("Author: {}, Command: {}, args: {}", e.getAuthor().getName(), commande, Arrays.toString(args));
|
||||||
|
|
||||||
return new CommandContainer(brt, sansTete, splitSansTete, commande, args, e);
|
return new CommandContainer(brt, sansTete, splitSansTete, commande, args, e);
|
||||||
|
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
package net.Broken.Tools.Command;
|
package net.Broken.Tools.Command;
|
||||||
|
|
||||||
import net.Broken.BotConfigLoader;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import net.Broken.MainBot;
|
import java.util.Set;
|
||||||
import net.Broken.SlashCommand;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
|
|
||||||
import net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
import org.reflections.util.ClasspathHelper;
|
import org.reflections.util.ClasspathHelper;
|
||||||
import org.reflections.util.ConfigurationBuilder;
|
import org.reflections.util.ConfigurationBuilder;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import net.Broken.BotConfigLoader;
|
||||||
import java.util.Set;
|
import net.Broken.MainBot;
|
||||||
|
import net.Broken.SlashCommand;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
|
||||||
|
import net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,8 +70,8 @@ public class SlashCommandLoader {
|
|||||||
if (v.getSubcommands() != null) {
|
if (v.getSubcommands() != null) {
|
||||||
command.addSubcommands(v.getSubcommands());
|
command.addSubcommands(v.getSubcommands());
|
||||||
}
|
}
|
||||||
// TODO Change slash command perm
|
command.setDefaultPermissions(v.getDefaultPermissions());
|
||||||
command.setDefaultEnabled(!v.isDisableByDefault());
|
|
||||||
commandListUpdateAction.addCommands(command);
|
commandListUpdateAction.addCommands(command);
|
||||||
});
|
});
|
||||||
commandListUpdateAction.queue();
|
commandListUpdateAction.queue();
|
||||||
|
Loading…
Reference in New Issue
Block a user