Skip to content

Commit

Permalink
fix(commands): Null check possibly null types in decompile
Browse files Browse the repository at this point in the history
  • Loading branch information
Phoenix-Starlight committed Mar 16, 2024
1 parent d6d0923 commit 2232b28
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/seailz/discordjar/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Permission> util = new BitwiseUtil<>();
EnumSet<Permission> permissionsList = util.get(permissions, Permission.class);
Expand Down

0 comments on commit 2232b28

Please sign in to comment.