本文整理汇总了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));
}
}
示例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);
}
}
}
示例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();
}
}
示例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());
}
示例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);
}
示例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());
}
}
示例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();
}
}
示例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);
}
}
示例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());
}
示例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()
);
}
示例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();
}
}
示例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);
}
示例13: onGuildLeave
import net.dv8tion.jda.core.events.guild.GuildLeaveEvent; //导入依赖的package包/类
@Override
public void onGuildLeave(GuildLeaveEvent event) {
Utils.errExit("I got kicked.");
}
示例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();
}
示例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() + "`."
);
}