Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a check in reaction methods before calling getTextChannel() #1216

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,23 @@ public RestAction<Void> addReaction(@Nonnull String unicode)
@Override
public RestAction<Void> clearReactions()
{
if (!isFromType(ChannelType.TEXT))
throw new IllegalStateException("Cannot clear reactions from a message in a Group or PrivateChannel.");
DManstrator marked this conversation as resolved.
Show resolved Hide resolved
Checks.check(isFromType(ChannelType.TEXT), "Cannot clear reactions from a message in a Group or PrivateChannel.");
return getTextChannel().clearReactionsById(getId());
}

@Nonnull
@Override
public RestAction<Void> clearReactions(@Nonnull String unicode)
{
Checks.check(isFromType(ChannelType.TEXT), "Cannot clear reactions from a message in a Group or PrivateChannel.");
return getTextChannel().clearReactionsById(getId(), unicode);
}

@Nonnull
@Override
public RestAction<Void> clearReactions(@Nonnull Emote emote)
{
Checks.check(isFromType(ChannelType.TEXT), "Cannot clear reactions from a message in a Group or PrivateChannel.");
return getTextChannel().clearReactionsById(getId(), emote);
}

Expand All @@ -193,6 +194,7 @@ public RestAction<Void> removeReaction(@Nonnull Emote emote)
@Override
public RestAction<Void> removeReaction(@Nonnull Emote emote, @Nonnull User user)
{
Checks.check(isFromType(ChannelType.TEXT), "Cannot remove reactions of others from a message in a Group or PrivateChannel.");
return getTextChannel().removeReactionById(getIdLong(), emote, user);
}

Expand All @@ -207,6 +209,7 @@ public RestAction<Void> removeReaction(@Nonnull String unicode)
@Override
public RestAction<Void> removeReaction(@Nonnull String unicode, @Nonnull User user)
{
Checks.check(isFromType(ChannelType.TEXT), "Cannot remove reactions of others from a message in a Group or PrivateChannel.");
return getTextChannel().removeReactionById(getId(), unicode, user);
}

Expand Down