Skip to content

Commit

Permalink
Remove warning about null interaction context
Browse files Browse the repository at this point in the history
Context is absent on guild-scoped commands
  • Loading branch information
freya022 committed Mar 26, 2024
1 parent c9e3656 commit df437a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ default DiscordLocale getGuildLocale()
return getGuild().getLocale();
}

//TODO document, maybe not null
//TODO document
@Nullable
InteractionContextType getContext();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,11 @@ public InteractionImpl(JDAImpl jda, DataObject data)
this.guild = jda.getGuildById(data.getUnsignedLong("guild_id", 0L));
this.channelId = data.getUnsignedLong("channel_id", 0L);
this.userLocale = DiscordLocale.from(data.getString("locale", "en-US"));
// Absent in guild-scoped commands
if (data.hasKey("context"))
this.context = InteractionContextType.fromKey(data.getString("context"));
else
{
//TODO someone claimed they received no context, it is documented as being nullable,
// but I've not seen context being null.
LOGGER.warn("No context provided in interaction");
this.context = null;
}
//TODO The bot and user permissions could be added in the temporary GuildChannel
// Meaning that you can still use (Self)Member#hasPermission(GuildChannel, Permission...) transparently
// The drawback is that the user might see the permission overrides and think they have them (document it)
Expand Down

0 comments on commit df437a5

Please sign in to comment.