summaryrefslogtreecommitdiff
path: root/src/main/java/net/uomc/mineshaft/resources/commands/RemoveResourceCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/uomc/mineshaft/resources/commands/RemoveResourceCommand.java')
-rw-r--r--src/main/java/net/uomc/mineshaft/resources/commands/RemoveResourceCommand.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/java/net/uomc/mineshaft/resources/commands/RemoveResourceCommand.java b/src/main/java/net/uomc/mineshaft/resources/commands/RemoveResourceCommand.java
new file mode 100644
index 0000000..2fadf27
--- /dev/null
+++ b/src/main/java/net/uomc/mineshaft/resources/commands/RemoveResourceCommand.java
@@ -0,0 +1,46 @@
+package net.uomc.mineshaft.resources.commands;
+
+import com.mouldycheerio.dbot.CustomBot;
+import com.mouldycheerio.dbot.commands.Command;
+import com.mouldycheerio.dbot.commands.CommandDetails;
+import com.mouldycheerio.dbot.util.PeelingUtils;
+
+import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
+import net.uomc.mineshaft.resources.ResourceManager;
+
+public class RemoveResourceCommand extends ResourceCommand implements Command {
+
+ public RemoveResourceCommand(ResourceManager resourceManager) {
+ super(resourceManager);
+ setCommandDetails(CommandDetails.hidden("removeItem"));
+ }
+
+ @Override
+ public void execute(MessageReceivedEvent e, CustomBot op, String[] args) {
+ String ownerid = op.getConfig().getString("ownerid");
+ if (ownerid.equals(e.getAuthor().getId())) {
+ if (args.length > 0) {
+ String name = args[0];
+ PeelingUtils.askQuestion(e, "Are you sure you want to delete **" + name + "**?\n(warning: all userdata will be lost)\nSend `confirm` to proceed", r -> {
+ if (r.equalsIgnoreCase("confirm")) {
+ boolean removeResource = getResourceManager().removeResource(name);
+ if (removeResource) {
+ op.sendMessage(e, "removed", "removed the item **" + name + "** from the list of items");
+
+ } else {
+ op.sendMessage(e, "not found", ":x: the item **" + name + "** was not found");
+ }
+ } else {
+ op.sendMessage(e, "cancelled", ":x: operation cancelled");
+
+ }
+ });
+ } else {
+ op.sendMessage(e, "incorrect usage", ":x: usage: `.removeResource [name]`");
+ }
+ } else {
+ op.sendMessage(e, "missing permissions", ":x: this command is not intended for you");
+ }
+ }
+
+}