Skip to content

Commit

Permalink
Fixed support ticket issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
KardasLand committed Apr 8, 2023
1 parent d485f29 commit 1bbc940
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.kardasland</groupId>
<artifactId>veldoryadiscord</artifactId>
<version>1.0</version>
<version>1.0.7</version>
<packaging>jar</packaging>

<name>VeldoryaJDA</name>
Expand Down Expand Up @@ -85,7 +85,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.1</version>
<version>5.0.0-beta.6</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/kardasland/discord/JDAThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/kardasland/discord/ticket/Ticket.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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<String> encodedList = ConfigManager.get("ticketdata.yml").getStringList("tickets");

String encoded = toString(this);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 1bbc940

Please sign in to comment.