Search in sources :

Example 1 with PrivateChannelCreateRequest

use of sx.blah.discord.api.internal.json.requests.PrivateChannelCreateRequest 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;
}
Also used : ChannelObject(sx.blah.discord.api.internal.json.objects.ChannelObject) DiscordException(sx.blah.discord.util.DiscordException) PrivateChannelCreateRequest(sx.blah.discord.api.internal.json.requests.PrivateChannelCreateRequest)

Aggregations

ChannelObject (sx.blah.discord.api.internal.json.objects.ChannelObject)1 PrivateChannelCreateRequest (sx.blah.discord.api.internal.json.requests.PrivateChannelCreateRequest)1 DiscordException (sx.blah.discord.util.DiscordException)1