Search in sources :

Example 11 with GuildObject

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

the class GuildCreateListener method onGuildCreateEvent.

@EventSubscriber
public void onGuildCreateEvent(GuildCreateEvent event) {
    IGuild guild = event.getGuild();
    long guildID = guild.getLongID();
    logger.debug("Starting Loading process for Guild with ID: " + guildID);
    if (new File(Utility.getDirectory(guildID)).exists()) {
        PatchHandler.guildPatches(guild);
    }
    FileHandler.createDirectory(Utility.getDirectory(guildID));
    FileHandler.createDirectory(Utility.getDirectory(guildID, true));
    FileHandler.createDirectory(Utility.getGuildImageDir(guildID));
    FileHandler.initFile(Utility.getFilePath(guildID, Constants.FILE_INFO));
    GuildObject guildObject = new GuildObject(guild);
    Globals.initGuild(guildObject);
    logger.info("Finished Loading Guild With ID: " + guildID);
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject) IGuild(sx.blah.discord.handle.obj.IGuild) File(java.io.File) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

Example 12 with GuildObject

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

the class LoggingHandler method doChannelCreateLog.

public static void doChannelCreateLog(ChannelCreateEvent event) {
    GuildObject content = Globals.getGuildContent(event.getGuild().getLongID());
    if (!content.config.moduleLogging)
        return;
    if (content.config.channelLogging) {
        String log = "> Channel " + event.getChannel().mention() + " was created.";
        Utility.sendLog(log, content, false);
    }
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject)

Example 13 with GuildObject

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

the class LoggingHandler method doJoinLeaveLog.

public static void doJoinLeaveLog(GuildMemberEvent event, boolean joining) {
    IGuild guild = event.getGuild();
    GuildObject content = Globals.getGuildContent(guild.getLongID());
    if (!content.config.moduleLogging)
        return;
    // name, descriminator, thinger, usercount.
    String output = "> **@%s#%s** %s.\n**Current Users:** %s.";
    output = String.format(output, event.getUser().getName(), event.getUser().getDiscriminator(), "%s", event.getGuild().getUsers().size());
    if (content.config.joinLeaveLogging) {
        if (joining) {
            Utility.sendLog(String.format(output, "has **Joined** the server"), content, false);
        } else {
            doKickLog(guild, event.getUser());
            Utility.sendLog(String.format(output, "has **Left** the server"), content, false);
        }
    }
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject)

Example 14 with GuildObject

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

the class LoggingHandler method doChannelDeleteLog.

public static void doChannelDeleteLog(ChannelDeleteEvent event) {
    GuildObject content = Globals.getGuildContent(event.getGuild().getLongID());
    if (!content.config.moduleLogging)
        return;
    if (content.config.channelLogging) {
        String log = "> Channel #" + event.getChannel().getName() + " was deleted.";
        Utility.sendLog(log, content, false);
    }
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject)

Example 15 with GuildObject

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

the class GetGlobalStats method execute.

@Override
public String execute(String args, CommandObject command) {
    ArrayList<ToggleStatsObject> toggleStats = new ArrayList<>();
    ArrayList<String> outToggles = new ArrayList<>();
    ArrayList<String> outModules = new ArrayList<>();
    // ArrayList<ChannelStatsObject> channelStats = new ArrayList<>();
    for (GuildToggle g : Globals.getGuildToggles()) {
        toggleStats.add(new ToggleStatsObject(g.name().toString(), g.isModule()));
    }
    // for (ChannelSetting c : Globals.getChannelSettings()) {
    // channelStats.add(new ChannelStatsObject(c.type(), c.isSetting()));
    // }
    long totalXpUsers = 0;
    long totalXP = 0;
    for (GuildObject g : Globals.getGuilds()) {
        CommandObject object = command.setGuild(g.get());
        for (ToggleStatsObject s : toggleStats) {
            for (GuildToggle t : object.guild.toggles) {
                if (t.name().toString().equalsIgnoreCase(s.getToggle())) {
                    if (t.isModule()) {
                        s.addOne();
                    } else if (t.enabled(object.guild.config) != t.getDefault()) {
                        s.addOne();
                    }
                }
            }
        }
        // }
        if (command.guild.config.modulePixels) {
            for (ProfileObject o : command.guild.users.getProfiles()) {
                if (o.getXP() != 0) {
                    totalXP += o.getXP();
                    totalXpUsers++;
                }
            }
        }
    }
    for (ToggleStatsObject t : toggleStats) {
        String formatted = t.getToggle() + ": " + t.getCount();
        if (t.isModule()) {
            outModules.add(formatted);
        } else {
            outToggles.add(formatted);
        }
    }
    StringBuilder output = new StringBuilder();
    output.append("**[GLOBAL STATS]**");
    output.append("\n\n**[TOGGLE STATS]**\n");
    output.append(Utility.listFormatter(outToggles, false));
    output.append("\n\n**[MODULE STATS]**\n");
    output.append(Utility.listFormatter(outModules, false));
    output.append("\n\n**[PIXEL STATS]**");
    output.append("\nAvg Pixels: " + totalXP / totalXpUsers);
    command.user.sendDm(output.toString());
    return "> Data sent to Your DMs";
// int totalGlobalUsers = 0;
// int totalAvg = 0;
// for (IGuild guild : command.client.getGuilds()) {
// StringBuilder builder = new StringBuilder();
// long totalUsers = 0;
// long totalMessage = 0;
// long totalMessageAvg = 0;
// long topGuild = 0;
// long bottomGuild = 0;
// String topUser = null;
// String bottomUser = null;
// GuildContentObject content = Globals.getGuildContent(guild.getLongID());
// for (UserTypeObject user : content.getGuildUsers().getProfiles()) {
// if (bottomGuild == 0) {
// bottomGuild = user.getXP();
// bottomUser = user.getID();
// } else if (bottomGuild > user.getXP()) {
// bottomGuild = user.getXP();
// bottomUser = user.getID();
// }
// if (topGuild == 0) {
// topGuild = user.getXP();
// topUser = user.getID();
// } else if (topGuild < user.getXP()) {
// topGuild = user.getXP();
// topUser = user.getID();
// }
// totalMessage += user.getXP();
// totalGlobalUsers++;
// totalUsers++;
// }
// builder.append("**Guild: " + guild.getNames() + "**");
// IUser topIUser = command.client.getUserByID(topUser);
// IUser bottomIUser = command.client.getUserByID(bottomUser);
// if (topIUser != null && bottomIUser != null) {
// builder.append("\nTop User = @" + command.client.getUserByID(topUser).getNames() + "#" + command.client.getUserByID(topUser).getDiscriminator());
// builder.append(" With Total Messages " + topGuild);
// builder.append("\nBottom User = @" + command.client.getUserByID(bottomUser).getNames() + "#" + command.client.getUserByID(bottomUser).getDiscriminator());
// builder.append(" With Total Messages " + bottomGuild);
// builder.append("\nGuild Avg = " + totalMessageAvg / totalUsers);
// builder.append("\nTotal Guild Messages = " + totalMessage);
// builder.append("\nTotal Users = " + totalUsers);
// Utility.sendDM(builder.toString(), command.authorSID);
// }
// try {
// Thread.sleep(2000);
// } catch (InterruptedException e) {
// Utility.sendStack(e);
// }
// }
// StringBuilder builder = new StringBuilder("**Global Stats**");
// builder.append("\nGlobal profiles = " + totalGlobalUsers);
// builder.append("\nGlobal Avg = " + totalAvg / totalGlobalUsers);
// Utility.sendDM(builder.toString(), command.authorSID);
// return null;
}
Also used : CommandObject(com.github.vaerys.commands.CommandObject) GuildObject(com.github.vaerys.masterobjects.GuildObject) GuildToggle(com.github.vaerys.templates.GuildToggle) ToggleStatsObject(com.github.vaerys.objects.ToggleStatsObject) ArrayList(java.util.ArrayList) ProfileObject(com.github.vaerys.objects.ProfileObject)

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