diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java index 96bd1d99..8c5afb3f 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java @@ -12,6 +12,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.IntStream; public class PreorderCommand extends CommandModule { @@ -102,10 +103,9 @@ public String obfuscateTransactionId(String transactionId) { if(transactionId.equals("NONE") || transactionId.equals("something")) return "Unknown"; StringBuilder sb = new StringBuilder(transactionId); - StringBuilder length = new StringBuilder(); - for(int i = 0; i < (int)(transactionId.length() / 1.5d); i++) length.append("\\*"); + String length = IntStream.range(0, (int) (transactionId.length() / 1.5d)).mapToObj(i -> "\\*").collect(Collectors.joining()); - sb.replace(0, (int)(transactionId.length() / 1.5d), length.toString()); + sb.replace(0, (int)(transactionId.length() / 1.5d), length); return sb.toString(); } diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/UserCheckCommand.java b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/UserCheckCommand.java index bd76684f..bc9b782d 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/UserCheckCommand.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/UserCheckCommand.java @@ -26,12 +26,6 @@ protected Query newQuery() { return bot.getRoles("Staff"); } }; - private final DefinedQuery STAFF_CHANNEL = new DefinedQuery() { - @Override - protected Query newQuery() { - return bot.getChannels("staff-chat"); - } - }; public UserCheckCommand(TechDiscordBot bot) { super(bot); } @@ -45,7 +39,7 @@ protected Query newQuery() { public DefinedQuery getRestrictedRoles() { return STAFF_ROLE; } @Override - public DefinedQuery getRestrictedChannels() { return STAFF_CHANNEL; } + public DefinedQuery getRestrictedChannels() { return null; } @Override public CommandCategory getCategory() { return CommandCategory.ADMIN; } diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/WikiCommand.java b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/WikiCommand.java index 165d3244..c31c0634 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/WikiCommand.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/cmds/WikiCommand.java @@ -44,6 +44,7 @@ public void onCommand(TextChannel channel, Message message, Member member, Strin new TechEmbedBuilder("Wiki Help").setText("**Wiki Command Args**\n\n`!wiki` - *If in a plugin support channel, shows that Wiki, otherwise shows your owned plugin's wikis.*\n`!wiki -a` - *Shows all wikis.*\n`wiki -m` - *Shows your wikis if in a plugin support channel.*").send(channel); return; } + if(Plugin.isPluginChannel(channel)) { if(args.length == 0) { showCurrentChannel(channel); @@ -72,6 +73,7 @@ public void showCurrentChannel(TextChannel channel) { new TechEmbedBuilder("Wikis").error().setText(plugin.getEmoji().getAsMention() + " " + plugin.getRoleName() + " unfortunately does not have a wiki!").sendTemporary(channel, 10); return; } + new TechEmbedBuilder("Wikis").setText("*Showing the wiki of the support channel you're in.*\n\n" + plugin.getEmoji().getAsMention() + " " + plugin.getWiki() + "\n\nFor more info please execute the command `wiki help`.").send(channel); } } @@ -80,20 +82,27 @@ public void showYourPlugins(Member member, TextChannel channel) { boolean apiIsUp = TechDiscordBot.getSpigotAPI().isAvailable(); List plugins = Plugin.allWithWiki(); if(apiIsUp) plugins = Plugin.fromUser(member).stream().filter(Plugin::hasWiki).collect(Collectors.toList()); + StringBuilder sb = new StringBuilder(); - if(!apiIsUp) sb.append(TechDiscordBot.getBot().getEmotes("offline").first().getAsMention()).append(" **The API is not online, showing all plugins with a wiki.**\n\n"); - if(apiIsUp) sb.append("*Showing all wikis of the plugins you own!*\n\n"); - if(plugins.isEmpty()) sb.append("**You do not own of any of Tech's plugins, showing all wikis!**\n\n"); - if(plugins.isEmpty()) plugins = Plugin.allWithWiki(); + if(!apiIsUp) + sb.append(TechDiscordBot.getBot().getEmotes("offline").first().getAsMention()).append(" **The API is not online, showing all plugins with a wiki.**\n\n"); + if(apiIsUp) + sb.append("*Showing all wikis of the plugins you own!*\n\n"); + if(plugins.isEmpty()) + sb.append("**You do not own of any of Tech's plugins, showing all wikis!**\n\n"); + if(plugins.isEmpty()) + plugins = Plugin.allWithWiki(); + plugins.forEach(p -> sb.append(p.getEmoji().getAsMention()).append(" ").append(p.getWiki()).append("\n")); - new TechEmbedBuilder("Wikis").setText(sb.toString().substring(0, sb.toString().length() - 1)).send(channel); + new TechEmbedBuilder("Wikis").setText(sb.substring(0, sb.toString().length() - 1)).send(channel); } public void showAll(TextChannel channel) { List plugins = Plugin.allWithWiki(); StringBuilder sb = new StringBuilder(); sb.append("*Showing all wikis!*\n\n"); + plugins.forEach(p -> sb.append(p.getEmoji().getAsMention()).append(" ").append(p.getWiki()).append("\n")); - new TechEmbedBuilder("Wikis").setText(sb.toString().substring(0, sb.toString().length() - 1)).send(channel); + new TechEmbedBuilder("Wikis").setText(sb.substring(0, sb.toString().length() - 1)).send(channel); } } \ No newline at end of file diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/ActivitiesModule.java b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/ActivitiesModule.java index aba9077d..4735dd03 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/ActivitiesModule.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/ActivitiesModule.java @@ -1,6 +1,5 @@ package me.TechsCode.TechDiscordBot.module.modules; -import me.TechsCode.SpigotAPI.client.objects.Resource; import me.TechsCode.SpigotAPI.client.objects.Review; import me.TechsCode.SpigotAPI.client.objects.Update; import me.TechsCode.TechDiscordBot.TechDiscordBot; @@ -41,14 +40,15 @@ public void onEnable() { TechDiscordBot.getSpigotAPI().getReviews().getStream().forEach(x -> announcedIds.add(x.getId())); TechDiscordBot.getSpigotAPI().getUpdates().getStream().forEach(x -> announcedIds.add(x.getId())); } - for(Resource resource : TechDiscordBot.getSpigotAPI().getResources().get()) { + + Arrays.stream(TechDiscordBot.getSpigotAPI().getResources().get()).forEach(resource -> { Plugin plugin = Plugin.fromId(resource.getId()); - if(plugin == null) continue; + if (plugin == null) return; Review[] newReviews = resource.getReviews().getStream().filter(x -> !announcedIds.contains(x.getId())).toArray(Review[]::new); Update[] newUpdates = resource.getUpdates().getStream().filter(x -> !announcedIds.contains(x.getId())).toArray(Update[]::new); Arrays.stream(newReviews).forEach(review -> printReview(plugin, review)); Arrays.stream(newUpdates).forEach(update -> printUpdate(plugin, update)); - } + }); } }).start(); } diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/ChatLogModule.java b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/ChatLogModule.java index c268ed23..7b001a4e 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/ChatLogModule.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/ChatLogModule.java @@ -25,11 +25,11 @@ protected Query newQuery() { } }; - private HashMap cachedMessages = new HashMap<>(); + private final HashMap cachedMessages = new HashMap<>(); private final DefinedQuery STAFF_ROLE = new DefinedQuery() { @Override - protected Query newQuery() { + protected Query newQuery() { return bot.getRoles("Staff"); } }; diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/EventsModule.java b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/EventsModule.java index 2e542e6e..22ab7789 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/EventsModule.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/EventsModule.java @@ -17,9 +17,7 @@ public EventsModule(TechDiscordBot bot) { } @Override - public void onEnable() { - - } + public void onEnable() {} @SubscribeEvent public void memberJoin(GuildMemberJoinEvent e) { diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/SongodaTransferModule.java b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/SongodaTransferModule.java index 058b6d7c..3b68a45a 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/SongodaTransferModule.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/SongodaTransferModule.java @@ -191,18 +191,21 @@ public void onChat(GuildMessageReceivedEvent e) { SongodaPurchase purchase = TechDiscordBot.getSongodaPurchases().stream() .filter(p -> p.getEmail() != null && p.getEmail().equals(e.getMessage().getContentDisplay())).findFirst().orElse(null); - email = purchase.getEmail(); - username = purchase.getUsername(); - - lastInstructions = new TechEmbedBuilder("Transfer to SpigotMC from Songoda (" + e.getAuthor().getName() + ")") - .setText("We've detected that you've bought " + plugins + " using your linked discord account.\n\nCould you please provide your Spigot Username?") - .send(TRANSFER_CHANNEL.query().first()); + if(purchase != null) { + email = purchase.getEmail(); + username = purchase.getUsername(); + + lastInstructions = new TechEmbedBuilder("Transfer to SpigotMC from Songoda (" + e.getAuthor().getName() + ")") + .setText("We've detected that you've bought " + plugins + " using your linked discord account.\n\nCould you please provide your Spigot Username?") + .send(TRANSFER_CHANNEL.query().first()); + } } } } public void sendTransferRequest(String songodaEmail, String songodaUsername, String spigotUsername, Member member) { member.getGuild().addRoleToMember(member, member.getGuild().getRolesByName("Requested-Transfer", true).get(0)).queue(); + new TechEmbedBuilder("Songoda Transfer Request") .setText("Request by " + member.getAsMention() + "\n\nPlugins - " + plugins + "\nSpigot Username - " + spigotUsername + "\n\nSongoda Email - " + (songodaEmail == null ? "N/A" : songodaEmail) + "\nSongoda Username - " + (songodaUsername == null ? "N/A" : songodaUsername)) .send(TRANSFER_STAFF_CHANNEL.query().first()); diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/SupportWrongChannelModule.java b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/SupportWrongChannelModule.java index e7f06fb8..56be31eb 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/SupportWrongChannelModule.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/SupportWrongChannelModule.java @@ -88,7 +88,6 @@ public void triggerMessage(TextChannel channel, Member member) { if (messages.containsValue(member.getId())) return; TextChannel verificationChannel = bot.getChannel("695493411117072425"); - TechEmbedBuilder teb = new TechEmbedBuilder().setText("Hello, " + member.getAsMention() + "! I've detected that you might be trying to get help in this channel! Please verify in " + verificationChannel.getAsMention() + " in order to get help, thanks!\n\n*If you are not trying to get help, you can delete this message by reacting to it!*") .error(); diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/TicketModule.java b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/TicketModule.java index 36324a60..0244580b 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/TicketModule.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/TicketModule.java @@ -191,6 +191,7 @@ public void startTimeout(String userId) { } catch (InterruptedException e) { e.printStackTrace(); } + if(this.selectionUserId == null || userId == null) return; if(this.selectionUserId.equals(userId) && isSelection) { new TechEmbedBuilder("Ticket - Error") @@ -284,8 +285,9 @@ public void onReactionAdd(MessageReactionAddEvent e) { sendIssueInstructions(e.getMember()); } else { String ezMention = TechDiscordBot.getJDA().getUserById("130340486920667136").getAsMention(); + new TechEmbedBuilder("Ticket Creation - Error") - .setText("This shouldn't be happening. Contact " + ezMention + " (EazyFTW#0001) immediately!") + .setText("This shouldn't be happening. Contact " + ezMention + " (ItsEazy#0001) immediately!") .error() .sendTemporary(channel, 10); isSelection = false; diff --git a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/VerificationModule.java b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/VerificationModule.java index 02eaa83a..ce42a8f7 100644 --- a/src/main/java/me/TechsCode/TechDiscordBot/module/modules/VerificationModule.java +++ b/src/main/java/me/TechsCode/TechDiscordBot/module/modules/VerificationModule.java @@ -30,7 +30,7 @@ public class VerificationModule extends Module { }; private TextChannel channel; - private Message lastInstructions, apiNotAvailable; + private Message lastInstructions; private List verificationQueue; @@ -43,7 +43,6 @@ public void onEnable() { channel = VERIFICATION_CHANNEL.query().first(); lastInstructions = null; - //apiNotAvailable = null; verificationQueue = new ArrayList<>(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { @@ -60,6 +59,7 @@ public void onDisable() { public void sendInstructions() { if(lastInstructions != null) lastInstructions.delete().complete(); + TechEmbedBuilder howItWorksMessage = new TechEmbedBuilder("How It Works").setText("Type your SpigotMC Username in this Chat to verify.\n\nVerification not working? Feel free to contact a staff member in <#311178000026566658>."); lastInstructions = howItWorksMessage.send(channel); } @@ -134,9 +134,11 @@ public void onMessage(GuildMessageReceivedEvent e) { .setText(e.getAuthor().getName() + " has successfully verified their SpigotMC Account!") .setThumbnail(avatarUrl) .send(channel); + sendInstructions(); verificationQueue.remove(e.getAuthor().getId()); TechDiscordBot.getStorage().createVerification(userId, e.getAuthor().getId()); + new TechEmbedBuilder("Verification Complete!") .setText("You've been successfully verified!\n\nHere are your purchased plugins: " + Plugin.getMembersPluginsinEmojis(e.getMember()) + "\n\n*Your roles will be updated automatically from now on!*") .setThumbnail(avatarUrl)