Skip to content

Commit

Permalink
Add GenericMessageEvent#getThreadChannel() (#1924)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Dec 2, 2021
1 parent 3d811bd commit 78803d6
Showing 1 changed file with 35 additions and 0 deletions.
Expand Up @@ -221,4 +221,39 @@ public PrivateChannel getPrivateChannel()
throw new IllegalStateException("This message event did not happen in a private channel");
return (PrivateChannel) channel;
}

/**
* The {@link net.dv8tion.jda.api.entities.ThreadChannel ThreadChannel} the Message was received in.
* <br>If this Message was not received in a {@link net.dv8tion.jda.api.entities.ThreadChannel ThreadChannel},
* this will throw an {@link java.lang.IllegalStateException}.
*
* @throws java.lang.IllegalStateException
* If this was not sent in a {@link net.dv8tion.jda.api.entities.ThreadChannel}.
*
* @return The ThreadChannel the Message was received in
*
* @see #isFromGuild()
* @see #isFromType(ChannelType)
* @see #getChannelType()
* @see #isFromThread()
*/
@Nonnull
public ThreadChannel getThreadChannel()
{
if (!isFromThread())
throw new IllegalStateException("This message event did not happen in a thread channel");
return (ThreadChannel) channel;
}

/**
* If the message event was from a {@link net.dv8tion.jda.api.entities.ThreadChannel ThreadChannel}
*
* @return If the message event was from a ThreadChannel
*
* @see ChannelType#isThread()
*/
public boolean isFromThread()
{
return getChannelType().isThread();
}
}

0 comments on commit 78803d6

Please sign in to comment.