From 10b327e9f6441a8863227ce3e075a5a587654065 Mon Sep 17 00:00:00 2001 From: davidovski Date: Sat, 11 Oct 2025 04:55:51 +0100 Subject: v0.3.1 --- .../resources/commands/RemoveResourceCommand.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/net/uomc/mineshaft/resources/commands/RemoveResourceCommand.java (limited to 'src/main/java/net/uomc/mineshaft/resources/commands/RemoveResourceCommand.java') 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"); + } + } + +} -- cgit v1.2.3