Skip to content

Commit

Permalink
Merge pull request #276 from Phoenix-Starlight/fix/null-check-command…
Browse files Browse the repository at this point in the history
…-decompile

fix(commands): Null check possibly null types in decompile
  • Loading branch information
seailz authored Mar 29, 2024
2 parents 5ad6539 + 2232b28 commit e4947d8
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 e4947d8

Please sign in to comment.