Skip to content

Commit

Permalink
* Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
DxsSucuk committed Jul 21, 2022
1 parent 482fef3 commit 3a7edf8
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/main/java/de/presti/ree6/commands/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public CommandManager() throws CommandInitializerException, InstantiationExcepti
Set<Class<? extends ICommand>> classes = reflections.getSubTypesOf(ICommand.class);

for (Class<? extends ICommand> aClass : classes) {
Main.getInstance().getAnalyticsLogger().info("Loading Command " + aClass.getSimpleName());
Main.getInstance().getAnalyticsLogger().info("Loading Command {}", aClass.getSimpleName());
addCommand(aClass.getDeclaredConstructor().newInstance());
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/de/presti/ree6/commands/impl/mod/Unmute.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public String[] getAlias() {
}

/**
* Unmutes a Member.
* Unmute a Member.
* @param executor The Executor.
* @param member The Member to unmute.
* @param commandEvent The CommandEvent.
Expand All @@ -93,9 +93,8 @@ public void unmuteMember(Member executor, Member member, CommandEvent commandEve
member.removeTimeout().onErrorFlatMap(throwable -> {
Main.getInstance().getCommandManager().sendMessage("Could not unmute " + member.getUser().getAsTag() + "!", 5, commandEvent.getChannel(), commandEvent.getInteractionHook());
return null;
}).queue(unused -> {
Main.getInstance().getCommandManager().sendMessage("User " + member.getAsMention() + " was unmuted!", 5, commandEvent.getChannel(), commandEvent.getInteractionHook());
});
}).queue(unused ->
Main.getInstance().getCommandManager().sendMessage("User " + member.getAsMention() + " was unmuted!", 5, commandEvent.getChannel(), commandEvent.getInteractionHook()));
Main.getInstance().getCommandManager().sendMessage("User " + member.getAsMention() + " has been unmuted!", 5, commandEvent.getChannel(), commandEvent.getInteractionHook());
} else {
if (!executor.canInteract(member)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public LogMessageMember(long webhookId, String webhookAuthCode, WebhookMessage w
* @param addedRoles the Added {@link Role} of the {@link Member}.
*/
public LogMessageMember(long webhookId, String webhookAuthCode, WebhookMessage webhookMessage, Guild guild, LogTyp logTyp, Member member,
ArrayList<Role> removedRoles, ArrayList<Role> addedRoles) {
List<Role> removedRoles, List<Role> addedRoles) {
super(webhookId, webhookAuthCode, webhookMessage, guild, logTyp);
this.member = member;
this.removedRoles = removedRoles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,6 @@ public Member getMember() {
return member;
}

/**
* Change the associated Member of the Log.
*
* @deprecated Will be removed.
* @param member the new {@link Member}.
*/
@Deprecated(since = "1.7.7", forRemoval = true)
public void setMember(Member member) {
this.member = member;
}

/**
* Get the previous {@link AudioChannel} of the {@link Member}
*
Expand All @@ -94,17 +83,6 @@ public AudioChannel getPreviousVoiceChannel() {
return previousVoiceChannel;
}

/**
* Change the previous {@link AudioChannel} of the {@link Member}
*
* @deprecated Will be removed.
* @param previousVoiceChannel the new previous {@link AudioChannel}.
*/
@Deprecated(since = "1.7.7", forRemoval = true)
public void setPreviousVoiceChannel(AudioChannel previousVoiceChannel) {
this.previousVoiceChannel = previousVoiceChannel;
}

/**
* Get the current {@link AudioChannel} of the {@link Member}
*
Expand All @@ -113,15 +91,4 @@ public void setPreviousVoiceChannel(AudioChannel previousVoiceChannel) {
public AudioChannel getCurrentVoiceChannel() {
return currentVoiceChannel;
}

/**
* Change the current {@link AudioChannel} of the {@link Member}
*
* @deprecated Will be removed.
* @param currentVoiceChannel the new current {@link AudioChannel}.
*/
@Deprecated(since = "1.7.7", forRemoval = true)
public void setCurrentVoiceChannel(AudioChannel currentVoiceChannel) {
this.currentVoiceChannel = currentVoiceChannel;
}
}
14 changes: 12 additions & 2 deletions src/main/java/de/presti/ree6/logger/invite/InviteContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@
public class InviteContainer {

/**
* information about the Invite.
* The ID of the Guild.
*/
String creatorId, guildId, code;
String guildId;

/**
* The ID of the creator.
*/
String creatorId;

/**
* The Code of the Invite.
*/
String code;

/**
* The use count from our Database.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/presti/ree6/utils/apis/GoogleVisionAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static String[] retrieveTextFromImage(byte[] imageBytes) {

for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
Main.getInstance().getAnalyticsLogger().error("Could not retrieve text from image: " + res.getError().getMessage());
Main.getInstance().getAnalyticsLogger().error("Could not retrieve text from image: {}", res.getError().getMessage());
return new String[0];
}

Expand Down Expand Up @@ -85,7 +85,7 @@ public static String[] retrieveTextFromImage(String fileUrl) {

for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
Main.getInstance().getAnalyticsLogger().error("Could not retrieve text from image: " + res.getError().getMessage());
Main.getInstance().getAnalyticsLogger().error("Could not retrieve text from image: {}", res.getError().getMessage());
return new String[0];
}

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/de/presti/ree6/utils/data/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.presti.ree6.utils.data;

import de.presti.ree6.main.Main;
import org.simpleyaml.configuration.file.YamlFile;

import java.io.File;
Expand Down Expand Up @@ -54,12 +55,14 @@ public void init() {

try {
yamlFile.save(getFile());
} catch (Exception ignored) {
} catch (Exception exception) {
Main.getInstance().getLogger().error("Could not save config file!", exception);
}
} else {
try {
yamlFile.load();
} catch (Exception ignored) {
} catch (Exception exception) {
Main.getInstance().getLogger().error("Could not load config!",exception);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
*/
public class AutoRoleHandler {

/**
* Constructor should not be called, since it is a utility class that doesn't need an instance.
*
* @throws IllegalStateException it is a utility class.
*/
private AutoRoleHandler() {
throw new IllegalStateException("Utility class");
}

/**
* Check if a Member should get a rule, when joining the Guild, and if Ree6 has enough permissions.
*
Expand Down

0 comments on commit 3a7edf8

Please sign in to comment.