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

The following examples show how to use net.dv8tion.jda.api.entities.VoiceChannel#getGuild() . 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: CheckOwnerQueueListener.java    From JuniperBot with GNU General Public License v3.0 6 votes vote down vote up
@RabbitListener(queues = RabbitConfiguration.QUEUE_CHECK_OWNER_REQUEST)
public boolean isAdministrator(CheckOwnerRequest request) {
    Guild guild = null;
    switch (request.getType()) {
        case TEXT:
            TextChannel textChannel = discordService.getTextChannelById(request.getChannelId());
            if (textChannel != null) {
                guild = textChannel.getGuild();
            }
            break;
        case VOICE:
            VoiceChannel voiceChannel = discordService.getVoiceChannelById(request.getChannelId());
            if (voiceChannel != null) {
                guild = voiceChannel.getGuild();
            }
            break;
    }
    if (guild == null) {
        return true;
    }
    Member member = guild.getMemberById(request.getUserId());
    if (member == null) {
        return false;
    }
    return member.isOwner() || member.hasPermission(Permission.ADMINISTRATOR);
}
 
Example 2
Source File: VoiceLinkListener.java    From JuniperBot with GNU General Public License v3.0 5 votes vote down vote up
private Role getRole(GuildConfig config, VoiceChannel channel) {
    if (channel == null) {
        return null;
    }
    Guild guild = channel.getGuild();
    return config.getVoiceLinks()
            .stream()
            .filter(e -> channel.getId().equals(e.getChannelId()))
            .findFirst()
            .map(e -> guild.getRoleById(e.getRoleId()))
            .filter(e -> guild.getSelfMember().canInteract(e))
            .orElse(null);
}
 
Example 3
Source File: AudioConnection.java    From JDA with Apache License 2.0 5 votes vote down vote up
public AudioConnection(AudioManagerImpl manager, String endpoint, String sessionId, String token, VoiceChannel channel)
{
    this.api = (JDAImpl) channel.getJDA();
    this.channel = channel;
    final JDAImpl api = (JDAImpl) channel.getJDA();
    this.threadIdentifier = api.getIdentifierString() + " AudioConnection Guild: " + channel.getGuild().getId();
    this.webSocket = new AudioWebSocket(this, manager.getListenerProxy(), endpoint, channel.getGuild(), sessionId, token, manager.isAutoReconnect());
}