Skip to content

Commit

Permalink
Added multiple missing Permission checks and fixed Shiba Command Exce…
Browse files Browse the repository at this point in the history
…ption.
  • Loading branch information
DxsSucuk committed Jul 2, 2024
1 parent 23e7b2d commit e35d401
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/de/presti/ree6/commands/impl/fun/ShibaImage.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.presti.ree6.commands.impl.fun;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import de.presti.ree6.bot.BotWorker;
import de.presti.ree6.commands.Category;
import de.presti.ree6.commands.CommandEvent;
Expand All @@ -23,7 +24,14 @@ public class ShibaImage implements ICommand {
*/
@Override
public void onPerform(CommandEvent commandEvent) {
JsonArray js = RequestUtility.requestJson(RequestUtility.Request.builder().url("https://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true").build()).getAsJsonArray();
JsonElement jsonElement = RequestUtility.requestJson(RequestUtility.Request.builder().url("https://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true").build());

if (jsonElement.isJsonObject()) {
commandEvent.reply(commandEvent.getResource("message.default.retrievalError"), 5);
return;
}

JsonArray js = jsonElement.getAsJsonArray();

EmbedBuilder em = new EmbedBuilder();

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/de/presti/ree6/commands/impl/mod/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ public void onPerform(CommandEvent commandEvent) {

switch (commandEvent.getSubcommandGroup()) {
case "auditlog" -> {
if (!commandEvent.getGuild().getSelfMember().hasPermission(Permission.MANAGE_WEBHOOKS)) {
commandEvent.reply(commandEvent.getResource("message.default.insufficientPermission", Permission.MANAGE_WEBHOOKS.name()));
return;
}

if (commandEvent.getSubcommand().equals("set")) {
if (guildChannelUnion.getType() == ChannelType.TEXT) {
guildChannelUnion.asTextChannel().createWebhook(BotConfig.getBotName() + "-Logs").queue(webhook -> {
Expand All @@ -158,6 +163,11 @@ public void onPerform(CommandEvent commandEvent) {
}
}
case "welcome" -> {
if (!commandEvent.getGuild().getSelfMember().hasPermission(Permission.MANAGE_WEBHOOKS)) {
commandEvent.reply(commandEvent.getResource("message.default.insufficientPermission", Permission.MANAGE_WEBHOOKS.name()));
return;
}

if (commandEvent.getSubcommand().equals("set")) {
if (guildChannelUnion.getType() == ChannelType.TEXT) {
guildChannelUnion.asTextChannel().createWebhook(BotConfig.getBotName() + "-Welcome").queue(webhook -> {
Expand Down

0 comments on commit e35d401

Please sign in to comment.