Remove obsolete PurgeCommand
This commit is contained in:
1 parent
47e8332931
commit
1ced46e075
1 file changed
-94
@@ -1,94 +0,0 @@
|
|||||||
package netneutrality.command.admin;
|
|
||||||
/*
|
|
||||||
* Copyright (c) anthorob
|
|
||||||
*
|
|
||||||
* https://discord.gg/qUa6zNFZsd
|
|
||||||
*/
|
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
|
||||||
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.SlashCommandData;
|
|
||||||
import netneutrality.command.AbstractCommand;
|
|
||||||
import netneutrality.command.CommandType;
|
|
||||||
import netneutrality.core.context.MessageCommandContext;
|
|
||||||
import netneutrality.core.context.SlashCommandContext;
|
|
||||||
import netneutrality.utils.ChannelMessagePurger;
|
|
||||||
|
|
||||||
public class PurgeCommand extends AbstractCommand {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean needAdmin() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGuildOnly() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return "purge";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return "Delete messages from the channel you are currently on";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DefaultMemberPermissions getSlashCommandPermission() {
|
|
||||||
return DefaultMemberPermissions.DISABLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerSlashCommandOptions(SlashCommandData data) {
|
|
||||||
|
|
||||||
data.addOptions(
|
|
||||||
new OptionData(OptionType.INTEGER, "to-purge", "Number of messages to delete (max 2500)", true)
|
|
||||||
.setRequiredRange(1, 2500));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandType getType() {
|
|
||||||
return CommandType.ADMINISTRATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(MessageCommandContext context) {
|
|
||||||
if (context.getArgs().length == 1) {
|
|
||||||
GuildMessageChannel messageChannel = context.getEvent().getGuildChannel();
|
|
||||||
ChannelMessagePurger channelMessagePurger = ChannelMessagePurger.getPurger(messageChannel);
|
|
||||||
channelMessagePurger.purgeMessages(context, Integer.parseInt(context.getArgument(0)));
|
|
||||||
} else {
|
|
||||||
context.getChannel().sendMessage("Failed to delete messages!").queue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(SlashCommandContext context) {
|
|
||||||
int toDelete = context.getEvent().getOption("to-purge", 0, OptionMapping::getAsInt);
|
|
||||||
context.ackAndWait(true);
|
|
||||||
|
|
||||||
if (toDelete > 0) {
|
|
||||||
GuildMessageChannel messageChannel = context.getEvent().getGuildChannel();
|
|
||||||
ChannelMessagePurger channelMessagePurger = ChannelMessagePurger.getPurger(messageChannel);
|
|
||||||
boolean lock = channelMessagePurger.canLockBeAcquired();
|
|
||||||
channelMessagePurger.purgeMessages(context, toDelete);
|
|
||||||
|
|
||||||
context.replyEphemeral("Processing purge command.. This can take some time.");
|
|
||||||
|
|
||||||
if (!lock) {
|
|
||||||
context.replyEphemeral("Another purge is currently in progress on this channel, please wait before purging again");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user