Skip to content

Commit

Permalink
Fixed up a minor few things...
Browse files Browse the repository at this point in the history
  • Loading branch information
RealMangorage committed May 22, 2024
1 parent a78e08b commit 6abf50e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'

installer('org.mangorage:installer:3.0.22')
bot('org.mangorage:mangobot:10.0.399')
bot('org.mangorage:mangobot:+')

library('org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5')
library('org.kohsuke:github-api:1.321')
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/org/mangorage/mangobot/MangoBotPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@
import static org.mangorage.mangobot.core.BotPermissions.PREFIX_ADMIN;
import static org.mangorage.mangobot.core.BotPermissions.TRICK_ADMIN;

import java.awt.*;
import java.nio.file.Path;
import java.util.Date;
import java.util.EnumSet;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import org.mangorage.basicutils.config.Config;
Expand All @@ -48,6 +44,7 @@
import org.mangorage.mangobot.core.BotEventListener;
import org.mangorage.mangobot.core.BotPermissions;
import org.mangorage.mangobot.core.Listeners;
import org.mangorage.mangobot.modules.actions.TrashButtonAction;
import org.mangorage.mangobot.modules.basic.commands.GetEmbedsCommand;
import org.mangorage.mangobot.modules.basic.commands.HelpCommand;
import org.mangorage.mangobot.modules.basic.commands.InfoCommand;
Expand Down Expand Up @@ -90,7 +87,6 @@
import org.mangorage.mangobotapi.core.events.LoadEvent;
import org.mangorage.mangobotapi.core.events.SaveEvent;
import org.mangorage.mangobotapi.core.modules.action.ButtonActionRegistry;
import org.mangorage.mangobotapi.core.modules.action.TrashButtonAction;
import org.mangorage.mangobotapi.core.plugin.api.CorePlugin;
import org.mangorage.mangobotapi.core.plugin.api.PluginMessageEvent;
import org.mangorage.mangobotapi.core.plugin.impl.Plugin;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2024. MangoRage
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
* OR OTHER DEALINGS IN THE SOFTWARE.
*/

package org.mangorage.mangobot.modules.actions;

import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
import org.mangorage.mangobotapi.core.modules.action.ButtonAction;

public class TrashButtonAction extends ButtonAction {

public TrashButtonAction() {
super("trash", "Delete");
}

public Button createForUser(User user) {
return create(ButtonStyle.DANGER, user.getId());
}

@Override
public boolean onClick(ButtonInteractionEvent event) {
if (event.getComponent().getId() == null) return false;

if (event.getComponent().getId().startsWith(getId() + ":")) {
var list = event.getComponent().getId().split(":");
var clicked = event.getUser().getId();
var msg = event.getMessage();

if (list[1].equals(clicked)) {
msg.delete().queue();
event.deferReply(true).setContent("Deleted Message!").queue();
} else {
event.deferReply(true).setContent("No permission to delete message!").queue();
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.interactions.components.ActionRow;
import net.dv8tion.jda.api.interactions.components.Component;
import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;
import net.dv8tion.jda.api.interactions.components.text.TextInput;
import net.dv8tion.jda.api.interactions.components.text.TextInputStyle;
import net.dv8tion.jda.api.interactions.modals.Modal;
import net.dv8tion.jda.api.utils.FileUpload;
import net.dv8tion.jda.api.utils.MarkdownSanitizer;
import net.dv8tion.jda.api.utils.MarkdownUtil;
import net.dv8tion.jda.internal.interactions.component.ButtonImpl;
import org.jetbrains.annotations.NotNull;
import org.mangorage.basicutils.LogHelper;
import org.mangorage.basicutils.TaskScheduler;
Expand All @@ -27,6 +21,7 @@
import org.mangorage.jdautils.command.Command;
import org.mangorage.jdautils.command.CommandOption;
import org.mangorage.mangobot.MangoBotPlugin;
import org.mangorage.mangobot.modules.actions.TrashButtonAction;
import org.mangorage.mangobotapi.core.commands.Arguments;
import org.mangorage.mangobotapi.core.commands.CommandAlias;
import org.mangorage.mangobotapi.core.commands.CommandResult;
Expand All @@ -36,24 +31,14 @@
import org.mangorage.mangobotapi.core.events.DiscordEvent;
import org.mangorage.mangobotapi.core.events.LoadEvent;
import org.mangorage.mangobotapi.core.events.SaveEvent;
import org.mangorage.mangobotapi.core.events.discord.DButtonInteractionEvent;
import org.mangorage.mangobotapi.core.events.discord.DModalInteractionEvent;
import org.mangorage.mangobotapi.core.modules.action.TrashButtonAction;
import org.mangorage.mangobotapi.core.plugin.api.CorePlugin;
import org.mangorage.mangobotapi.core.util.MessageSettings;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.lang.runtime.SwitchBootstraps;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

public class TrickCommand implements IBasicCommand {
private static final boolean ALLOW_SCRIPT_TRICKS = true;
private final CorePlugin plugin;
Expand Down

0 comments on commit 6abf50e

Please sign in to comment.