From 2232b28ffdb066a7b2625f412a44792626fa8a8e Mon Sep 17 00:00:00 2001 From: Fury_Phoenix <64714532+Phoenix-Starlight@users.noreply.github.com> Date: Fri, 15 Mar 2024 21:48:50 -0700 Subject: [PATCH] fix(commands): Null check possibly null types in decompile --- src/main/java/com/seailz/discordjar/command/Command.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/seailz/discordjar/command/Command.java b/src/main/java/com/seailz/discordjar/command/Command.java index ecee0993..f8ecbfb4 100644 --- a/src/main/java/com/seailz/discordjar/command/Command.java +++ b/src/main/java/com/seailz/discordjar/command/Command.java @@ -89,21 +89,21 @@ public static Command decompile(JSONObject obj) { boolean canUseInDms = true; boolean nsfw = false; - if (obj.has("name_localizations")) { + if (obj.has("name_localizations") && !obj.isNull("name_localizations")) { JSONObject nameLocalesJson = obj.getJSONObject("name_localizations"); for (String locale : nameLocalesJson.keySet()) { nameLocales.put(locale, nameLocalesJson.getString(locale)); } } - if (obj.has("description_localizations")) { + if (obj.has("description_localizations") && !obj.isNull("description_localizations")) { JSONObject descriptionLocalesJson = obj.getJSONObject("description_localizations"); for (String locale : descriptionLocalesJson.keySet()) { descriptionLocales.put(locale, descriptionLocalesJson.getString(locale)); } } - if (obj.has("default_member_permissions")) { + if (obj.has("default_member_permissions") && !obj.isNull("default_member_permissions")) { int permissions = obj.getInt("default_member_permissions"); BitwiseUtil util = new BitwiseUtil<>(); EnumSet permissionsList = util.get(permissions, Permission.class);