Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
The bug of the Level command not working from time to time was fixed, as well as the createchannel command not giving Read-permission. Also I added a console command to add and list new bugs without having to stop the bot whilst being available for later fixing!
  • Loading branch information
Gregor7008 committed Feb 24, 2022
1 parent 8b77ae8 commit 17321fb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
24 changes: 24 additions & 0 deletions src/main/java/base/Bot.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package base;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Writer;
import java.util.List;

import javax.security.auth.login.LoginException;
Expand Down Expand Up @@ -137,6 +141,26 @@ private void readConsole() {
case "warn":
Configloader.INSTANCE.addUserConfig(jda.getGuildById(insplit[1]), jda.getUserById(insplit[2]), "warnings", "Administrative actions");
System.out.println("User " + jda.retrieveUserById(insplit[2]).complete().getName() + " was successfully warned on " + jda.getGuildById(insplit[1]).getName());
break;
case "listbugs":
try (BufferedReader br = new BufferedReader(new FileReader(new File(environment + "/configs/bugs.txt")))) {
String fileline;
while ((fileline = br.readLine()) != null) {
System.out.println(fileline);
}
}
break;
case "addbugs":
try {
Writer output = new BufferedWriter(new FileWriter(environment + "/configs/bugs.txt", true));
String[] bug = line.split(" ", 2);
output.append(bug[1]);
output.close();
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Invalid arguments!\nAdd the new bug behind the command!");
break;
}

break;
default:
System.out.println("Unknown command!");
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/base/Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,9 @@ private void managej2cjoin(Guild guild, Member member, VoiceChannel channeljoine
//check for Join2create-channel & create User-channel if true
String j2cids = Configloader.INSTANCE.getGuildConfig(guild, "join2create");
if (j2cids.contains(channeljoined.getId())) {
channeljoined.putPermissionOverride(guild.getPublicRole()).setDeny(Permission.VOICE_SPEAK).queue();
channeljoined.upsertPermissionOverride(guild.getPublicRole()).deny(Permission.VOICE_SPEAK).queue();
Collection<Permission> perms = new LinkedList<Permission>();
perms.add(Permission.VIEW_CHANNEL);
perms.add(Permission.MANAGE_CHANNEL);
perms.add(Permission.MANAGE_PERMISSIONS);
perms.add(Permission.CREATE_INSTANT_INVITE);
Expand Down Expand Up @@ -332,6 +333,7 @@ private void managej2cleave(Guild guild, User user, VoiceChannel channelleft) {
} else {
if (Configloader.INSTANCE.getGuildConfig(guild, "j2cs").contains(vc.getId() + "-" + user.getId())) {
Collection<Permission> perms = new LinkedList<Permission>();
perms.add(Permission.VIEW_CHANNEL);
perms.add(Permission.MANAGE_CHANNEL);
perms.add(Permission.MANAGE_PERMISSIONS);
perms.add(Permission.CREATE_INSTANT_INVITE);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/commands/utilities/CreateChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void createTextChannel(Guild guild, User user, String name) {
cgy = guild.createCategory(user.getName() + "'s channels").complete();
cgy.putPermissionOverride(guild.getPublicRole()).setDeny(Permission.VIEW_CHANNEL).queue();
cgy.putPermissionOverride(guild.getMember(user)).setAllow(perms).queue();
cgy.upsertPermissionOverride(guild.getMember(user)).setDeny(Permission.MESSAGE_MENTION_EVERYONE).queue();
cgy.upsertPermissionOverride(guild.getMember(user)).deny(Permission.MESSAGE_MENTION_EVERYONE).queue();
Configloader.INSTANCE.addGuildConfig(guild, "ccctgies", cgy.getId());
if (!Configloader.INSTANCE.getGuildConfig(guild, "ccdefaccess").equals("")) {
String[] defroles = Configloader.INSTANCE.getGuildConfig(guild, "ccdefaccess").split(";");
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/commands/utilities/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class Level implements Command {
public void perform(SlashCommandEvent event) {
Guild guild = event.getGuild();
User user;
event.deferReply(true);
try {
user = event.getOption("user").getAsUser();
} catch (NullPointerException e) {
Expand All @@ -44,8 +43,9 @@ public void perform(SlashCommandEvent event) {
event.replyEmbeds(AnswerEngine.ae.buildMessage("...", ":face_exhaling: | You think you're funny or what?")).queue(r -> r.deleteOriginal().queueAfter(3, TimeUnit.SECONDS));
return;
}
event.reply("... ... ... ...").queue();
File finalimage = this.renderLevelcard(user, guild);
event.reply("").addFile(finalimage).queue();
event.getHook().editOriginal("").addFile(finalimage).queue();
}

@Override
Expand Down Expand Up @@ -101,16 +101,16 @@ public File renderLevelcard(User iuser, Guild guild) {
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//write Level
g2d.setFont(new Font("Calibri", Font.PLAIN, 65));
g2d.setFont(new Font("Calibri", 0, 40));
g2d.setColor(Color.decode("#5773c9"));
g2d.drawString(String.valueOf(level), 813, 95);
//write XP
g2d.setFont(new Font("Calibri", Font.PLAIN, 30));
g2d.setFont(new Font("Calibri", 0, 20));
g2d.setColor(Color.WHITE);
String temp1 = curxp + "\s/\s" + String.valueOf(nedxp);
g2d.drawString(temp1, 820 - g2d.getFontMetrics().stringWidth(temp1), 170);
//write iusername
g2d.setFont(new Font("Calibri", Font.PLAIN, 50));
g2d.setFont(new Font("Calibri", 0, 17));
g2d.setColor(Color.WHITE);
g2d.drawString(guild.getMember(iuser).getEffectiveName(), 293, 170);
//draw Icon
Expand Down

0 comments on commit 17321fb

Please sign in to comment.