当前位置: 首页>>代码示例>>Java>>正文


Java GuildVoiceLeaveEvent类代码示例

本文整理汇总了Java中net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent的典型用法代码示例。如果您正苦于以下问题:Java GuildVoiceLeaveEvent类的具体用法?Java GuildVoiceLeaveEvent怎么用?Java GuildVoiceLeaveEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GuildVoiceLeaveEvent类属于net.dv8tion.jda.core.events.guild.voice包,在下文中一共展示了GuildVoiceLeaveEvent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event)
{
    Guild guild = event.getGuild();
    TextChannel tc = db.getServerlogChannel(guild);
    TextChannel channel = FinderUtil.getDefaultChannel(event.getGuild());
    VoiceChannel vc = event.getChannelLeft();
    User user = event.getMember().getUser();
    Calendar calendar = GregorianCalendar.getInstance();
    calendar.setTime(new Date());
    String hour = String.format("%02d",calendar.get(Calendar.HOUR_OF_DAY));
    String min = String.format("%02d", calendar.get(Calendar.MINUTE));
    String sec = String.format("%02d", calendar.get(Calendar.SECOND));

    if(!(tc==null) && !(user.isBot()))
    {
        if(!(tc.getGuild().getSelfMember().hasPermission(tc, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_HISTORY)))
            guild.getOwner().getUser().openPrivateChannel().queue(s -> s.sendMessage(Messages.SRVLOG_NOPERMISSIONS).queue(
                    null, (e) -> channel.sendMessage(Messages.SRVLOG_NOPERMISSIONS).queue()));
        else
            tc.sendMessage("`["+hour+":"+min+":"+sec+"] [Voice Left]:` **"+user.getName()+"#"+user.getDiscriminator()+"** left a Voice Channel: **"+vc.getName()+"**").queue();
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:24,代码来源:ServerLogging.java

示例2: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
	// Ignore guilds that are not related to this instance
	if (e.getGuild().getId() != guildId) {
		return;
	}
	// Ignore voice channels that are not linked
	if (!channelsAndMembers.containsKey(e.getChannelLeft())) {
		return;
	}
	// Ignore if the user joins a linked channel
	if (channelsAndMembers.containsKey(e.getMember().getVoiceState().getChannel())) {
		return;
	}
	
	channelsAndMembers.forEach((c, ms) -> ms.remove(e.getMember()));
}
 
开发者ID:Tazzie02,项目名称:Tazbot,代码行数:18,代码来源:LinkUnlink.java

示例3: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
    if(e.getChannelLeft().getMembers().size() == 0) {
        if (e.getChannelLeft().getName().contains("[AC]")) {
            e.getChannelLeft().delete().queue();
        }
    }
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:9,代码来源:AutochannelListener.java

示例4: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
    if (!isEventEnabled(event.getGuild(), LogEventKeys.VOICE))
        return;
    TextChannel textChannel = getLogChannel(event.getGuild());
    if (textChannel == null)
        return;

    EmbedBuilder embedBuilder = new EmbedBuilder();
    embedBuilder.setAuthor("A member closed voice connection", null, event.getMember().getUser().getAvatarUrl());
    embedBuilder.setDescription("**" + event.getMember().getEffectiveName() + " (" + event.getMember().getUser().getId() + ")** left `" + event.getChannelLeft().getName() + "`");
    embedBuilder.setColor(evVoiceLog);
    sendLog(textChannel, embedBuilder);
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:15,代码来源:ServerLogHandler.java

示例5: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
	if (e.getGuild().getAudioManager().getConnectedChannel() != null) {
		if (e.getChannelLeft().equals(e.getGuild().getAudioManager().getConnectedChannel())
				&& e.getChannelLeft().getMembers().size() == 1
				&& (GuildObject.guildMap.get(e.getGuild().getId()).getMusicManager() != null
						&& GuildObject.guildMap.get(e.getGuild().getId()).getMusicManager().getTrackManager().isEmpty())) {
			e.getGuild().getAudioManager().closeAudioConnection();
			GuildObject.guildMap.get(e.getGuild().getId()).getMusicManager().reset();
			log.info("Left a voice channel: {}", e.getGuild().getId());
		}
	}
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:14,代码来源:VoiceChannelListeners.java

示例6: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
    // Check if not ourselves
    if (!event.getMember().getUser().equals(event.getJDA().getSelfUser())) return;

    getLink(event.getGuild()).onVoiceLeave();
}
 
开发者ID:Frederikam,项目名称:Lavalink,代码行数:8,代码来源:Lavalink.java

示例7: onEvent

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onEvent(Event event) {
    if(event instanceof GuildVoiceMoveEvent) {
        onGuildVoiceMove((GuildVoiceMoveEvent)event);
    } else if(event instanceof GuildVoiceJoinEvent) {
        onGuildVoiceJoin((GuildVoiceJoinEvent)event);
    } else if(event instanceof GuildVoiceLeaveEvent) {
        onGuildVoiceLeave((GuildVoiceLeaveEvent)event);
    } else if(event instanceof GuildVoiceMuteEvent) {
        onGuildVoiceMute((GuildVoiceMuteEvent)event);
    }
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:13,代码来源:MusicListener.java

示例8: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
	if (voiceChannel.getChannel().getId().equals(e.getChannelLeft().getId())) {
		if (voiceChannel.getChannel().getMembers().isEmpty()) {
			deleteChannel();
		}
	}
}
 
开发者ID:Tazzie02,项目名称:Tazbot,代码行数:9,代码来源:TempChannel.java

示例9: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
    if (!players.containsKey(event.getGuild().getId()))
        return; //Guild doesn't have a music player

    TrackManager manager = getTrackManager(event.getGuild());
    manager.getQueuedTracks().stream()
            .filter(info -> !info.getTrack().equals(getPlayer(event.getGuild()).getPlayingTrack())
                    && info.getAuthor().getUser().equals(event.getMember().getUser()))
            .forEach(manager::remove);
}
 
开发者ID:DinosParkour,项目名称:deeJay,代码行数:12,代码来源:MusicCommand.java

示例10: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
    if (event.getMember().getUser().equals(event.getJDA().getSelfUser())) {
        if (MinehutBot.get().getMusicManager().hasPlayer(event.getGuild().getId())) {
            MinehutBot.get().getMusicManager().getPlayer(event.getGuild().getId()).getPlaylist().clear();
            MinehutBot.get().getMusicManager().getPlayer(event.getGuild().getId()).skip();
        }
    }
}
 
开发者ID:Minehut,项目名称:MinehutBOT,代码行数:10,代码来源:VoiceEvents.java

示例11: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
public final void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
    Standard.log(Instant.now(), event.getGuild(), LOG_NAME, LOG_CHANNEL_ID_VOICE, LOG_TEXT_VOICE_LEAVE, "[%1$s] [%2$s] %3$s left #%4$s", LOG_DATE_TIME_FORMAT, Config.CONFIG.getUserNameForUser(event.getMember().getUser(), event.getGuild(), true), event.getChannelLeft().getName());
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:5,代码来源:GuildVoiceLogger.java

示例12: onGuildVoiceLeave

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) {
    if(event.getChannelLeft().getMembers().contains(event.getGuild().getSelfMember()))
        onLeave(event.getChannelLeft());
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:5,代码来源:MusicListener.java

示例13: handleInternally

import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; //导入依赖的package包/类
@Override
protected Long handleInternally(JSONObject content)
{
    final long id = content.getLong("guild_id");
    if (api.getGuildLock().isLocked(id))
        return id;

    GuildImpl guild = (GuildImpl) api.getGuildMap().get(id);
    if(guild == null)
    {
        //We probably just left the guild and this event is trying to remove us from the guild, therefore ignore
        return null;
    }

    final long userId = content.getJSONObject("user").getLong("id");
    if (userId == api.getSelfUser().getIdLong())
    {
        //We probably just left the guild and this event is trying to remove us from the guild, therefore ignore
        return null;
    }
    MemberImpl member = (MemberImpl) guild.getMembersMap().remove(userId);

    if (member == null)
    {
        WebSocketClient.LOG.debug("Received GUILD_MEMBER_REMOVE for a Member that does not exist in the specified Guild.");
        return null;
    }

    if (member.getVoiceState().inVoiceChannel())//If this user was in a VoiceChannel, fire VoiceLeaveEvent.
    {
        GuildVoiceStateImpl vState = (GuildVoiceStateImpl) member.getVoiceState();
        VoiceChannel channel = vState.getChannel();
        vState.setConnectedChannel(null);
        ((VoiceChannelImpl) channel).getConnectedMembersMap().remove(member.getUser().getIdLong());
        api.getEventManager().handle(
                new GuildVoiceLeaveEvent(
                        api, responseNumber,
                        member, channel));
    }

    //The user is not in a different guild that we share
    // The user also is not a friend of this account in the case that the logged in account is a client account.
    if (userId != api.getSelfUser().getIdLong() // don't remove selfUser from cache
        && api.getGuildMap().valueCollection().stream().noneMatch(g -> ((GuildImpl) g).getMembersMap().containsKey(userId))
        && !(api.getAccountType() == AccountType.CLIENT && api.asClient().getFriendById(userId) != null))
    {
        UserImpl user = (UserImpl) api.getUserMap().remove(userId);
        if (user.hasPrivateChannel())
        {
            PrivateChannelImpl priv = (PrivateChannelImpl) user.getPrivateChannel();
            user.setFake(true);
            priv.setFake(true);
            api.getFakeUserMap().put(user.getIdLong(), user);
            api.getFakePrivateChannelMap().put(priv.getIdLong(), priv);
        }
        else if (api.getAccountType() == AccountType.CLIENT)
        {
            //While the user might not have a private channel, if this is a client account then the user
            // could be in a Group, and if so we need to change the User object to be fake and
            // place it in the FakeUserMap
            for (Group grp : api.asClient().getGroups())
            {
                if (grp.getNonFriendUsers().contains(user))
                {
                    user.setFake(true);
                    api.getFakeUserMap().put(user.getIdLong(), user);
                    break; //Breaks from groups loop
                }
            }
        }
        api.getEventCache().clear(EventCache.Type.USER, userId);
    }
    api.getEventManager().handle(
            new GuildMemberLeaveEvent(
                    api, responseNumber,
                    guild, member));
    return null;
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:79,代码来源:GuildMemberRemoveHandler.java


注:本文中的net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。