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


Java GuildLeaveEvent类代码示例

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


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

示例1: onEvent

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Listener
@Override
public void onEvent(Event event) {
	if (event instanceof ShardMonitorEvent) {
		((ShardMonitorEvent) event).alive(shardId, ShardMonitorEvent.MANTARO_LISTENER);
		return;
	}

	if (event instanceof GuildJoinEvent) {
		Async.thread("LogThread", () -> onJoin((GuildJoinEvent) event));
		return;
	}

	if (event instanceof GuildLeaveEvent) {
		Async.thread("LogThread", () -> onLeave((GuildLeaveEvent) event));
	}

	if (event instanceof StatusChangeEvent) {
		ThreadPoolHelper.defaultPool().startThread("LogThread", () -> logStatusChange((StatusChangeEvent) event));
	}
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:22,代码来源:MantaroListener.java

示例2: onLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
private void onLeave(GuildLeaveEvent event) {
	try {
		TextChannel tc = getLogChannel();
		String hour = df.format(new Date(System.currentTimeMillis()));

		if (event.getGuild().getMembers().isEmpty()) {
			tc.sendMessage(String.format(EmoteReference.THINKING + "`[%s]` A guild with name: ``%s`` just got deleted.", hour, event.getGuild().getName())).queue();
			logTotal++;
			return;
		}

		tc.sendMessage(String.format(EmoteReference.SAD + "`[%s]` I left a guild with name: ``%s`` (%s members)", hour, event.getGuild().getName(), event.getGuild().getMembers().size())).queue();
		logTotal++;

		GuildStatsManager.log(LoggedEvent.LEAVE);
	} catch (Exception e) {
		if (!(e instanceof NullPointerException) && !(e instanceof IllegalArgumentException)) {
			log.warn("Unexpected error while logging a leave event.", e);
		}
	}
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:22,代码来源:MantaroListener.java

示例3: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event)
{
    Guild guild = event.getGuild();
    User owner = guild.getOwner().getUser();
    LoggerFactory.getLogger("Logging").info("[GUILD LEFT]: "+guild.getName()+" (ID: "+guild.getId()+")\n");
    long botCount = guild.getMembers().stream().map(m -> m.getUser()).filter(u -> u.isBot()).count();
    long userCount = guild.getMembers().stream().map(m -> m.getUser()).filter(u -> !(u.isBot())).count();
    long totalCount = guild.getMembers().size();
    TextChannel tc = event.getJDA().getTextChannelById(config.getBotlogChannelId());
    String reason = getReason(guild);

    if(config.isBotlogEnabled() && !(tc==null) && tc.canTalk())
    {
        StringBuilder builder = new StringBuilder().append(":outbox_tray: `[Left Guild]:` "+guild.getName()+" (ID: "+guild.getId()+")\n" +
                "`[Owner]:` **"+owner.getName()+"**#**"+owner.getDiscriminator()+"** (ID: "+owner.getId()+"\n" +
                "`[Members]:` Humans: **"+userCount+"** Bots: **"+botCount+"** Total Count: **"+totalCount+"**\n");

        if(!(reason==null))
            builder.append("`[Reason]:` "+reason);

        tc.sendMessage(builder.toString()).queue();
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:25,代码来源:GuildEvents.java

示例4: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave( GuildLeaveEvent event )
{
    /* Disabled reactive database pruning as the Discord API seems to like to send GuildLeave notifications
       during discord outages

    // purge the leaving guild's entry list
    Main.getDBDriver().getEventCollection().deleteMany(eq("guildId", event.getGuild().getId()));
    // remove the guild's schedules
    Main.getDBDriver().getScheduleCollection().deleteMany(eq("guildId", event.getGuild().getId()));
    // remove the guild's settings
    Main.getDBDriver().getGuildCollection().deleteOne(eq("_id", event.getGuild().getId()));
    */

    JDA.ShardInfo info = event.getJDA().getShardInfo();
    HttpUtilities.updateStats(info==null ? null : info.getShardId());
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:18,代码来源:EventListener.java

示例5: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(final GuildLeaveEvent event) {
    final Guild guild = event.getGuild();

    int gamesDestroyed = 0;
    //destroy games running in the server that was left
    for (final Game game : Games.getAll().values()) {
        if (game.getGuildId() == guild.getIdLong()) {
            try {
                game.destroy(new UserFriendlyException("Bot was kicked from the server " + guild.getName() + " " + guild.getIdLong()));
                gamesDestroyed++;
            } catch (final Exception e) {
                log.error("Exception when destroying a game in channel `{}` after leaving guild `{}`",
                        game.getChannelId(), guild.getIdLong(), e);
            }
        }
    }

    DiscordLogger.getLogger().log("%s `%s` Left guild %s with %s users, destroyed **%s** games.",
            Emojis.X, TextchatUtils.berlinTime(), guild.getName(), guild.getMembers().size(), gamesDestroyed);
}
 
开发者ID:napstr,项目名称:wolfia,代码行数:22,代码来源:InternalListener.java

示例6: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event) {
    if (KekBot.player.containsConnection(event.getGuild())) {
        event.getGuild().getAudioManager().closeAudioConnection();
        KekBot.player.killConnection(event.getGuild());
    }

    if (!GSONUtils.getConfig().getBlockedUsers().contains(event.getGuild().getOwner().getUser().getId())) {
        for (JDA jda : KekBot.jdas) {
            try {
                jda.getUserById(GSONUtils.getConfig().getBotOwner()).openPrivateChannel().queue(ch -> ch.sendMessage("Left/Kicked from server: \"" + event.getGuild().getName() + "\" (ID: " + event.getGuild().getId() + ")").queue());
                break;
            } catch (NullPointerException | IllegalStateException e) {
                //do nothing.
            }
        }
        File folder = new File("settings/" + event.getGuild().getId());
        Utils.deleteDirectory(folder);
        Utils.sendStats(event.getJDA());
    }
}
 
开发者ID:Godson777,项目名称:KekBot,代码行数:22,代码来源:Listener.java

示例7: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event) {
    final Instant timestamp = Instant.now();
    if (Standard.getConsoleTextChannel() != null) {
        Standard.getConsoleTextChannel().sendMessage(String.format("[%s] Left guild %s", LocalDateTime.ofInstant(timestamp, getZoneId()).format(DateTimeFormatter.ofPattern(Standard.STANDARD_DATE_TIME_FORMAT)), Standard.getCompleteName(event.getGuild()))).queue();
    }
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:8,代码来源:GuildLogger.java

示例8: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
/**
 * Removes the guild from the database
 * @param e
 */
@Override
public void onGuildLeave(GuildLeaveEvent e) {
    //post statistics to discordbots.org
    DBLUtil.postStats(e.getJDA());
    try {
        if(RubiconBot.getMySQL().ifGuildExits(e.getGuild())) {
            RubiconBot.getMySQL().deleteGuild(e.getGuild());
        }
    } catch (Exception ex) {
        Logger.error(ex);
    }
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:17,代码来源:BotLeaveListener.java

示例9: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event) {
    if (!avaire.areWeReadyYet()) {
        return;
    }

    Metrics.guilds.dec();
    Metrics.geoTracker.labels(event.getGuild().getRegion().getName()).dec();
    EventLogger.logGuildLeave(avaire, event);

    AvaIre.getLogger().info("Left guild with an ID of " + event.getGuild().getId() + " called: " + event.getGuild().getName());
}
 
开发者ID:avaire,项目名称:avaire,代码行数:13,代码来源:GuildJoinLeave.java

示例10: logGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
public static void logGuildLeave(AvaIre avaire, GuildLeaveEvent event) {
    if (!isWebhookEnabled(avaire)) {
        return;
    }

    GUILD_MESSAGES.add(new EmbedBuilder()
        .setColor(Color.decode("#EF5350"))
        .setTimestamp(Instant.now())
        .addField("Removed", String.format("%s (ID: %s)",
            event.getGuild().getName(), event.getGuild().getId()
        ), false)
        .build()
    );
}
 
开发者ID:avaire,项目名称:avaire,代码行数:15,代码来源:EventLogger.java

示例11: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent e) {
	if (!Bot.isReady)
		return;
	try {
		FileUtils.deleteDirectory(new File("resources/guilds/" + e.getGuild().getId() + "/"));
		GuildObject.guildMap.remove(e.getGuild().getId());
		log.info("Guild has left: {}", e.getGuild().getName());
	} catch (IOException e1) {
		e1.printStackTrace();
	}
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:13,代码来源:Listeners.java

示例12: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent e) {
	Guild g = e.getGuild();
	String message = "LEFT GUILD " + JDAUtil.guildToString(g);
	
	// Set joined to false in settings file
	SettingsManager settingsManager = SettingsManager.getInstance(g.getId());
	settingsManager.getSettings().setJoined(false);
	settingsManager.saveSettings();
	
	MessageLogger.guildEvent(g, message);
	SendMessage.sendDeveloper(message);
}
 
开发者ID:Tazzie02,项目名称:Tazbot,代码行数:14,代码来源:Listeners.java

示例13: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event) {
	Utils.errExit("I got kicked.");
}
 
开发者ID:Bleuzen,项目名称:Blizcord,代码行数:5,代码来源:Bot.java

示例14: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event) {
    DatabaseUtils.deleteGuildSettings(bot.getDatabase(), event.getGuild());
    bot.updateBotLists();
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:6,代码来源:DiscordShard.java

示例15: onGuildLeave

import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event) {
    send(
            "[:x:] Left guild `" + event.getGuild() + "`. Users: `" + event.getGuild().getMembers().size() + "`."
    );
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:7,代码来源:EventLogger.java


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