Java Code Examples for net.dv8tion.jda.api.entities.VoiceChannel#getIdLong()

The following examples show how to use net.dv8tion.jda.api.entities.VoiceChannel#getIdLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectionRequest.java    From JDA with Apache License 2.0 5 votes vote down vote up
public ConnectionRequest(VoiceChannel channel, ConnectionStage stage)
{
    this.channelId = channel.getIdLong();
    this.guildId = channel.getGuild().getIdLong();
    this.stage = stage;
    this.nextAttemptEpoch = System.currentTimeMillis();
}
 
Example 2
Source File: WebSocketClient.java    From JDA with Apache License 2.0 5 votes vote down vote up
public ConnectionRequest updateAudioConnection0(long guildId, VoiceChannel connectedChannel)
{
    //Called by VoiceStateUpdateHandler when we receive a response from discord
    // about our request to CONNECT or DISCONNECT.
    // "stage" should never be RECONNECT here thus we don't check for that case
    ConnectionRequest request = queuedAudioConnections.get(guildId);

    if (request == null)
        return null;
    ConnectionStage requestStage = request.getStage();
    if (connectedChannel == null)
    {
        //If we got an update that DISCONNECT happened
        // -> If it was on RECONNECT we now switch to CONNECT
        // -> If it was on DISCONNECT we can now remove it
        // -> Otherwise we ignore it
        switch (requestStage)
        {
            case DISCONNECT:
                return queuedAudioConnections.remove(guildId);
            case RECONNECT:
                request.setStage(ConnectionStage.CONNECT);
                request.setNextAttemptEpoch(System.currentTimeMillis());
            default:
                return null;
        }
    }
    else if (requestStage == ConnectionStage.CONNECT)
    {
        //If the removeRequest was related to a channel that isn't the currently queued
        // request, then don't remove it.
        if (request.getChannelId() == connectedChannel.getIdLong())
            return queuedAudioConnections.remove(guildId);
    }
    //If the channel is not the one we are looking for!
    return null;
}
 
Example 3
Source File: ConnectionRequest.java    From JDA with Apache License 2.0 4 votes vote down vote up
public void setChannel(VoiceChannel channel)
{
    this.channelId = channel.getIdLong();
}