use of sx.blah.discord.api.internal.json.objects.ChannelObject in project Discord4J by Discord4J.
the class ShardImpl method getOrCreatePMChannel.
@Override
public IPrivateChannel getOrCreatePMChannel(IUser user) {
checkReady("get PM channel");
if (user.equals(getClient().getOurUser()))
throw new DiscordException("Cannot PM yourself!");
IPrivateChannel channel = privateChannels.get(user.getLongID());
if (channel != null)
return channel;
ChannelObject pmChannel = client.REQUESTS.POST.makeRequest(DiscordEndpoints.USERS + getClient().getOurUser().getStringID() + "/channels", new PrivateChannelCreateRequest(user.getStringID()), ChannelObject.class);
channel = (IPrivateChannel) DiscordUtils.getChannelFromJSON(this, null, pmChannel);
privateChannels.put(channel);
return channel;
}
Aggregations