diff --git a/pom.xml b/pom.xml index 76806cd..d94f65b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.kardasland veldoryadiscord - 1.0 + 1.0.7 jar VeldoryaJDA @@ -85,7 +85,7 @@ net.dv8tion JDA - 5.0.0-beta.1 + 5.0.0-beta.6 provided diff --git a/src/main/java/com/kardasland/discord/JDAThread.java b/src/main/java/com/kardasland/discord/JDAThread.java index 3c6a7e0..3ec37f2 100644 --- a/src/main/java/com/kardasland/discord/JDAThread.java +++ b/src/main/java/com/kardasland/discord/JDAThread.java @@ -120,8 +120,12 @@ public void run() { guild.loadMembers(); System.out.println("Connected to Discord Bot successfully."); - TextChannel channel = guild.getTextChannelById(ConfigManager.get("config.yml").getString("discord.channels.verify")); - channel.upsertPermissionOverride(Objects.requireNonNull(guild.getMemberById(jda.getSelfUser().getId()))).setAllowed(Permission.MESSAGE_MANAGE).queue(); + + // Fixed verify id cannot be empty issue. + if (VeldoryaJDA.instance.tryLoadModule("verifyModule", "verify")){ + TextChannel channel = guild.getTextChannelById(ConfigManager.get("config.yml").getString("discord.channels.verify")); + channel.upsertPermissionOverride(Objects.requireNonNull(guild.getMemberById(jda.getSelfUser().getId()))).setAllowed(Permission.MESSAGE_MANAGE).queue(); + } //System.out.println("Permission MANAGE_CHANNEL: " + PermissionUtil.checkPermission(guild.getSelfMember(), Permission.MANAGE_CHANNEL)); if (ConfigManager.get("config.yml").getBoolean("modules.ticketModule")){ TextChannel ticketChannel = guild.getTextChannelById(ticketSystem.getString("ticketChannel")); diff --git a/src/main/java/com/kardasland/discord/ticket/ModalListener.java b/src/main/java/com/kardasland/discord/ticket/ModalListener.java index e60268c..2f8ca8a 100644 --- a/src/main/java/com/kardasland/discord/ticket/ModalListener.java +++ b/src/main/java/com/kardasland/discord/ticket/ModalListener.java @@ -213,6 +213,7 @@ public void onModalInteraction(@Nonnull ModalInteractionEvent event) { } } ticket.createNewTicket(); + //event.getHook().editOriginal("a").queue(); event.getHook().editOriginal(ConfigManager.get("ticketsystem.yml").getString("messages.ticketOpened").replaceAll("%mentionticket%", event.getGuild().getTextChannelsByName(ticket.channelName, true).get(0).getAsMention())).queue(); } catch (IOException | ClassNotFoundException e) { throw new RuntimeException(e); diff --git a/src/main/java/com/kardasland/discord/ticket/Ticket.java b/src/main/java/com/kardasland/discord/ticket/Ticket.java index 3e8b7ea..0688b76 100644 --- a/src/main/java/com/kardasland/discord/ticket/Ticket.java +++ b/src/main/java/com/kardasland/discord/ticket/Ticket.java @@ -17,6 +17,7 @@ import net.dv8tion.jda.api.interactions.components.buttons.Button; import net.dv8tion.jda.api.managers.channel.ChannelManager; import net.dv8tion.jda.api.managers.channel.concrete.TextChannelManager; +import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.scheduler.BukkitRunnable; @@ -63,6 +64,7 @@ public void createNewTicket() throws IOException { this.channelName = ticketSystem.getString("ticketFormat") .replace("%number%", String.valueOf(ticketSize)) .replace("%member%", VeldoryaJDA.instance.getGuild().getMemberById(ownerID).getUser().getName()).replaceAll("[^a-zA-Z0-9]", " "); + this.channelName = channelName.replace(" ", "-"); ticketData.set("number", ticketSize); ConfigManager.save("ticketdata.yml"); ConfigManager.reload("ticketdata.yml"); @@ -71,10 +73,12 @@ public void createNewTicket() throws IOException { .addPermissionOverride(VeldoryaJDA.instance.getGuild().getMemberById(ownerID), EnumSet.of(Permission.VIEW_CHANNEL, Permission.MESSAGE_SEND), null) .addPermissionOverride(VeldoryaJDA.instance.getGuild().getPublicRole(), null, EnumSet.of(Permission.VIEW_CHANNEL, Permission.MESSAGE_SEND)) .complete(); - TextChannel textChannel = category.getJDA().getTextChannelsByName(channelName, true).get(0); - channelID = textChannel.getId(); - makeRest(textChannel); - + for (TextChannel textChannel : category.getTextChannels()){ + if (textChannel.getName().equalsIgnoreCase(this.channelName)){ + channelID = textChannel.getId(); + makeRest(textChannel); + } + } List encodedList = ConfigManager.get("ticketdata.yml").getStringList("tickets"); String encoded = toString(this); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 22fa492..648da92 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,10 @@ name: VeldoryaDiscord -version: '1.0.6' +version: '1.0.7' main: com.kardasland.veldoryadiscord.VeldoryaJDA api-version: 1.16 website: www.kardasland.com libraries: - - net.dv8tion:JDA:5.0.0-beta.1 + - net.dv8tion:JDA:5.0.0-beta.6 - mysql:mysql-connector-java:8.0.30 - com.zaxxer:HikariCP:4.0.3 commands: