本文整理汇总了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();
}
}
示例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()));
}
示例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();
}
}
}
示例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);
}
示例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());
}
}
}
示例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();
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
示例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();
}
}
}
示例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());
}
示例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());
}
示例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;
}