Search in sources :

Example 6 with GuildObject

use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.

the class Globals method backupAll.

public static void backupAll() {
    if (shuttingDown) {
        return;
    }
    savingFiles = true;
    logger.debug("Backing up Files.");
    // global files
    if (dailyMessages != null)
        dailyMessages.backUp();
    if (events != null)
        events.backUp();
    if (globalData != null)
        globalData.backUp();
    // guild files
    for (GuildObject g : guilds) {
        for (GuildFile file : g.guildFiles) {
            file.backUp();
        }
    }
    savingFiles = false;
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject)

Example 7 with GuildObject

use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.

the class Globals method unloadGuild.

public static void unloadGuild(long id) {
    ListIterator iterator = guilds.listIterator();
    while (iterator.hasNext()) {
        GuildObject guild = (GuildObject) iterator.next();
        if (guild.longID == id) {
            logger.info("Guild: " + guild.get().getName() + " unloaded.");
            iterator.remove();
        }
    }
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject)

Example 8 with GuildObject

use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.

the class Globals method saveFiles.

public static void saveFiles(boolean shuttingDown) {
    if (shuttingDown)
        Globals.shuttingDown = true;
    else if (Globals.shuttingDown || Globals.savingFiles)
        return;
    savingFiles = true;
    logger.debug("Saving Files.");
    // global files
    if (dailyMessages != null)
        dailyMessages.flushFile();
    if (events != null)
        events.flushFile();
    if (globalData != null)
        globalData.flushFile();
    // guild files
    for (GuildObject g : guilds) {
        for (GuildFile file : g.guildFiles) {
            file.flushFile();
        }
    }
    savingFiles = false;
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject)

Example 9 with GuildObject

use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.

the class Globals method initGuild.

public static void initGuild(GuildObject guild) {
    for (GuildObject g : guilds) {
        if (g.longID == guild.longID) {
            return;
        }
    }
    guild.config.updateVariables(guild.get());
    guilds.add(guild);
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject)

Example 10 with GuildObject

use of com.github.vaerys.masterobjects.GuildObject in project DiscordSailv2 by Vaerys-Dawn.

the class Utility method sendGlobalAdminLogging.

public static void sendGlobalAdminLogging(Command command, String args, CommandObject commandObject) {
    for (GuildObject c : Globals.getGuilds()) {
        StringHandler message = new StringHandler("***GLOBAL LOGGING***\n> **@").append(commandObject.user.username).append("** Has Used Command `").append(command.names[0]).append("`");
        List<IChannel> adminlog = c.getChannelsByType(ChannelSetting.ADMIN_LOG);
        List<IChannel> serverLog = c.getChannelsByType(ChannelSetting.SERVER_LOG);
        IChannel channel = null;
        if (!(args == null || args.isEmpty())) {
            message.append(" with args: `" + args + "`");
        }
        if (serverLog.size() != 0) {
            channel = serverLog.get(0);
        }
        if (adminlog.size() != 0) {
            channel = adminlog.get(0);
        }
        if (channel != null) {
            RequestHandler.sendMessage(message.toString(), channel);
        }
    }
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject) StringHandler(com.github.vaerys.handlers.StringHandler)

Aggregations

GuildObject (com.github.vaerys.masterobjects.GuildObject)21 CommandObject (com.github.vaerys.commands.CommandObject)5 ZonedDateTime (java.time.ZonedDateTime)5 ArrayList (java.util.ArrayList)4 UserRoleUpdateEvent (sx.blah.discord.handle.impl.events.guild.member.UserRoleUpdateEvent)4 ChannelSetting (com.github.vaerys.enums.ChannelSetting)3 Client (com.github.vaerys.main.Client)3 Globals (com.github.vaerys.main.Globals)3 Utility (com.github.vaerys.main.Utility)3 Instant (java.time.Instant)3 ZoneOffset (java.time.ZoneOffset)3 Comparator (java.util.Comparator)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 DiscordUtils (sx.blah.discord.api.internal.DiscordUtils)3 EmbedObject (sx.blah.discord.api.internal.json.objects.EmbedObject)3 ActionType (sx.blah.discord.handle.audit.ActionType)3 AuditLogEntry (sx.blah.discord.handle.audit.entry.AuditLogEntry)3