Skip to content

Commit 376009c

Browse files
author
EazyFTW
committed
More cleanup.
1 parent 80d3c2d commit 376009c

File tree

10 files changed

+42
-35
lines changed

10 files changed

+42
-35
lines changed

src/main/java/me/TechsCode/TechDiscordBot/module/cmds/PreorderCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Arrays;
1313
import java.util.List;
1414
import java.util.stream.Collectors;
15+
import java.util.stream.IntStream;
1516

1617
public class PreorderCommand extends CommandModule {
1718

@@ -102,10 +103,9 @@ public String obfuscateTransactionId(String transactionId) {
102103
if(transactionId.equals("NONE") || transactionId.equals("something")) return "Unknown";
103104
StringBuilder sb = new StringBuilder(transactionId);
104105

105-
StringBuilder length = new StringBuilder();
106-
for(int i = 0; i < (int)(transactionId.length() / 1.5d); i++) length.append("\\*");
106+
String length = IntStream.range(0, (int) (transactionId.length() / 1.5d)).mapToObj(i -> "\\*").collect(Collectors.joining());
107107

108-
sb.replace(0, (int)(transactionId.length() / 1.5d), length.toString());
108+
sb.replace(0, (int)(transactionId.length() / 1.5d), length);
109109
return sb.toString();
110110
}
111111

src/main/java/me/TechsCode/TechDiscordBot/module/cmds/UserCheckCommand.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ protected Query<Role> newQuery() {
2626
return bot.getRoles("Staff");
2727
}
2828
};
29-
private final DefinedQuery<TextChannel> STAFF_CHANNEL = new DefinedQuery<TextChannel>() {
30-
@Override
31-
protected Query<TextChannel> newQuery() {
32-
return bot.getChannels("staff-chat");
33-
}
34-
};
3529

3630
public UserCheckCommand(TechDiscordBot bot) { super(bot); }
3731

@@ -45,7 +39,7 @@ protected Query<TextChannel> newQuery() {
4539
public DefinedQuery<Role> getRestrictedRoles() { return STAFF_ROLE; }
4640

4741
@Override
48-
public DefinedQuery<TextChannel> getRestrictedChannels() { return STAFF_CHANNEL; }
42+
public DefinedQuery<TextChannel> getRestrictedChannels() { return null; }
4943

5044
@Override
5145
public CommandCategory getCategory() { return CommandCategory.ADMIN; }

src/main/java/me/TechsCode/TechDiscordBot/module/cmds/WikiCommand.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void onCommand(TextChannel channel, Message message, Member member, Strin
4444
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);
4545
return;
4646
}
47+
4748
if(Plugin.isPluginChannel(channel)) {
4849
if(args.length == 0) {
4950
showCurrentChannel(channel);
@@ -72,6 +73,7 @@ public void showCurrentChannel(TextChannel channel) {
7273
new TechEmbedBuilder("Wikis").error().setText(plugin.getEmoji().getAsMention() + " " + plugin.getRoleName() + " unfortunately does not have a wiki!").sendTemporary(channel, 10);
7374
return;
7475
}
76+
7577
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);
7678
}
7779
}
@@ -80,20 +82,27 @@ public void showYourPlugins(Member member, TextChannel channel) {
8082
boolean apiIsUp = TechDiscordBot.getSpigotAPI().isAvailable();
8183
List<Plugin> plugins = Plugin.allWithWiki();
8284
if(apiIsUp) plugins = Plugin.fromUser(member).stream().filter(Plugin::hasWiki).collect(Collectors.toList());
85+
8386
StringBuilder sb = new StringBuilder();
84-
if(!apiIsUp) sb.append(TechDiscordBot.getBot().getEmotes("offline").first().getAsMention()).append(" **The API is not online, showing all plugins with a wiki.**\n\n");
85-
if(apiIsUp) sb.append("*Showing all wikis of the plugins you own!*\n\n");
86-
if(plugins.isEmpty()) sb.append("**You do not own of any of Tech's plugins, showing all wikis!**\n\n");
87-
if(plugins.isEmpty()) plugins = Plugin.allWithWiki();
87+
if(!apiIsUp)
88+
sb.append(TechDiscordBot.getBot().getEmotes("offline").first().getAsMention()).append(" **The API is not online, showing all plugins with a wiki.**\n\n");
89+
if(apiIsUp)
90+
sb.append("*Showing all wikis of the plugins you own!*\n\n");
91+
if(plugins.isEmpty())
92+
sb.append("**You do not own of any of Tech's plugins, showing all wikis!**\n\n");
93+
if(plugins.isEmpty())
94+
plugins = Plugin.allWithWiki();
95+
8896
plugins.forEach(p -> sb.append(p.getEmoji().getAsMention()).append(" ").append(p.getWiki()).append("\n"));
89-
new TechEmbedBuilder("Wikis").setText(sb.toString().substring(0, sb.toString().length() - 1)).send(channel);
97+
new TechEmbedBuilder("Wikis").setText(sb.substring(0, sb.toString().length() - 1)).send(channel);
9098
}
9199

92100
public void showAll(TextChannel channel) {
93101
List<Plugin> plugins = Plugin.allWithWiki();
94102
StringBuilder sb = new StringBuilder();
95103
sb.append("*Showing all wikis!*\n\n");
104+
96105
plugins.forEach(p -> sb.append(p.getEmoji().getAsMention()).append(" ").append(p.getWiki()).append("\n"));
97-
new TechEmbedBuilder("Wikis").setText(sb.toString().substring(0, sb.toString().length() - 1)).send(channel);
106+
new TechEmbedBuilder("Wikis").setText(sb.substring(0, sb.toString().length() - 1)).send(channel);
98107
}
99108
}

src/main/java/me/TechsCode/TechDiscordBot/module/modules/ActivitiesModule.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package me.TechsCode.TechDiscordBot.module.modules;
22

3-
import me.TechsCode.SpigotAPI.client.objects.Resource;
43
import me.TechsCode.SpigotAPI.client.objects.Review;
54
import me.TechsCode.SpigotAPI.client.objects.Update;
65
import me.TechsCode.TechDiscordBot.TechDiscordBot;
@@ -41,14 +40,15 @@ public void onEnable() {
4140
TechDiscordBot.getSpigotAPI().getReviews().getStream().forEach(x -> announcedIds.add(x.getId()));
4241
TechDiscordBot.getSpigotAPI().getUpdates().getStream().forEach(x -> announcedIds.add(x.getId()));
4342
}
44-
for(Resource resource : TechDiscordBot.getSpigotAPI().getResources().get()) {
43+
44+
Arrays.stream(TechDiscordBot.getSpigotAPI().getResources().get()).forEach(resource -> {
4545
Plugin plugin = Plugin.fromId(resource.getId());
46-
if(plugin == null) continue;
46+
if (plugin == null) return;
4747
Review[] newReviews = resource.getReviews().getStream().filter(x -> !announcedIds.contains(x.getId())).toArray(Review[]::new);
4848
Update[] newUpdates = resource.getUpdates().getStream().filter(x -> !announcedIds.contains(x.getId())).toArray(Update[]::new);
4949
Arrays.stream(newReviews).forEach(review -> printReview(plugin, review));
5050
Arrays.stream(newUpdates).forEach(update -> printUpdate(plugin, update));
51-
}
51+
});
5252
}
5353
}).start();
5454
}

src/main/java/me/TechsCode/TechDiscordBot/module/modules/ChatLogModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ protected Query<TextChannel> newQuery() {
2525
}
2626
};
2727

28-
private HashMap<String, Message> cachedMessages = new HashMap<>();
28+
private final HashMap<String, Message> cachedMessages = new HashMap<>();
2929

3030
private final DefinedQuery<Role> STAFF_ROLE = new DefinedQuery<Role>() {
3131
@Override
32-
protected Query newQuery() {
32+
protected Query<Role> newQuery() {
3333
return bot.getRoles("Staff");
3434
}
3535
};

src/main/java/me/TechsCode/TechDiscordBot/module/modules/EventsModule.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ public EventsModule(TechDiscordBot bot) {
1717
}
1818

1919
@Override
20-
public void onEnable() {
21-
22-
}
20+
public void onEnable() {}
2321

2422
@SubscribeEvent
2523
public void memberJoin(GuildMemberJoinEvent e) {

src/main/java/me/TechsCode/TechDiscordBot/module/modules/SongodaTransferModule.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,21 @@ public void onChat(GuildMessageReceivedEvent e) {
191191
SongodaPurchase purchase = TechDiscordBot.getSongodaPurchases().stream()
192192
.filter(p -> p.getEmail() != null && p.getEmail().equals(e.getMessage().getContentDisplay())).findFirst().orElse(null);
193193

194-
email = purchase.getEmail();
195-
username = purchase.getUsername();
196-
197-
lastInstructions = new TechEmbedBuilder("Transfer to SpigotMC from Songoda (" + e.getAuthor().getName() + ")")
198-
.setText("We've detected that you've bought " + plugins + " using your linked discord account.\n\nCould you please provide your Spigot Username?")
199-
.send(TRANSFER_CHANNEL.query().first());
194+
if(purchase != null) {
195+
email = purchase.getEmail();
196+
username = purchase.getUsername();
197+
198+
lastInstructions = new TechEmbedBuilder("Transfer to SpigotMC from Songoda (" + e.getAuthor().getName() + ")")
199+
.setText("We've detected that you've bought " + plugins + " using your linked discord account.\n\nCould you please provide your Spigot Username?")
200+
.send(TRANSFER_CHANNEL.query().first());
201+
}
200202
}
201203
}
202204
}
203205

204206
public void sendTransferRequest(String songodaEmail, String songodaUsername, String spigotUsername, Member member) {
205207
member.getGuild().addRoleToMember(member, member.getGuild().getRolesByName("Requested-Transfer", true).get(0)).queue();
208+
206209
new TechEmbedBuilder("Songoda Transfer Request")
207210
.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))
208211
.send(TRANSFER_STAFF_CHANNEL.query().first());

src/main/java/me/TechsCode/TechDiscordBot/module/modules/SupportWrongChannelModule.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public void triggerMessage(TextChannel channel, Member member) {
8888
if (messages.containsValue(member.getId())) return;
8989
TextChannel verificationChannel = bot.getChannel("695493411117072425");
9090

91-
9291
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!*")
9392
.error();
9493

src/main/java/me/TechsCode/TechDiscordBot/module/modules/TicketModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public void startTimeout(String userId) {
191191
} catch (InterruptedException e) {
192192
e.printStackTrace();
193193
}
194+
194195
if(this.selectionUserId == null || userId == null) return;
195196
if(this.selectionUserId.equals(userId) && isSelection) {
196197
new TechEmbedBuilder("Ticket - Error")
@@ -284,8 +285,9 @@ public void onReactionAdd(MessageReactionAddEvent e) {
284285
sendIssueInstructions(e.getMember());
285286
} else {
286287
String ezMention = TechDiscordBot.getJDA().getUserById("130340486920667136").getAsMention();
288+
287289
new TechEmbedBuilder("Ticket Creation - Error")
288-
.setText("This shouldn't be happening. Contact " + ezMention + " (EazyFTW#0001) immediately!")
290+
.setText("This shouldn't be happening. Contact " + ezMention + " (ItsEazy#0001) immediately!")
289291
.error()
290292
.sendTemporary(channel, 10);
291293
isSelection = false;

src/main/java/me/TechsCode/TechDiscordBot/module/modules/VerificationModule.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class VerificationModule extends Module {
3030
};
3131

3232
private TextChannel channel;
33-
private Message lastInstructions, apiNotAvailable;
33+
private Message lastInstructions;
3434

3535
private List<String> verificationQueue;
3636

@@ -43,7 +43,6 @@ public void onEnable() {
4343
channel = VERIFICATION_CHANNEL.query().first();
4444

4545
lastInstructions = null;
46-
//apiNotAvailable = null;
4746
verificationQueue = new ArrayList<>();
4847

4948
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
@@ -60,6 +59,7 @@ public void onDisable() {
6059

6160
public void sendInstructions() {
6261
if(lastInstructions != null) lastInstructions.delete().complete();
62+
6363
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>.");
6464
lastInstructions = howItWorksMessage.send(channel);
6565
}
@@ -134,9 +134,11 @@ public void onMessage(GuildMessageReceivedEvent e) {
134134
.setText(e.getAuthor().getName() + " has successfully verified their SpigotMC Account!")
135135
.setThumbnail(avatarUrl)
136136
.send(channel);
137+
137138
sendInstructions();
138139
verificationQueue.remove(e.getAuthor().getId());
139140
TechDiscordBot.getStorage().createVerification(userId, e.getAuthor().getId());
141+
140142
new TechEmbedBuilder("Verification Complete!")
141143
.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!*")
142144
.setThumbnail(avatarUrl)

0 commit comments

Comments
 (0)