Search in sources :

Example 1 with GuildObject

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

the class PixelHandler method isUnRanked.

public static boolean isUnRanked(long userID, GuildUsers users, IGuild guild) {
    ProfileObject user = users.getUserByID(userID);
    GuildObject guildObject = Globals.getGuildContent(guild.getLongID());
    if (user == null) {
        return true;
    }
    if (guild.getUserByID(userID) == null) {
        return true;
    }
    if (user.getXP() == 0) {
        return true;
    }
    for (UserSetting s : user.getSettings()) {
        for (UserSetting test : Constants.dontLogStates) {
            if (s == test) {
                return true;
            }
        }
    }
    ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
    long diff = now.toEpochSecond() - user.getLastTalked();
    long days = TimeUnit.DAYS.convert(diff, TimeUnit.SECONDS);
    if (days > 14 && guildObject.config.xpDecay && !user.getSettings().contains(UserSetting.DONT_DECAY)) {
        return true;
    }
    return false;
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject) ZonedDateTime(java.time.ZonedDateTime) ProfileObject(com.github.vaerys.objects.ProfileObject) UserSetting(com.github.vaerys.enums.UserSetting)

Example 2 with GuildObject

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

the class RequestHandler method muteUser.

public static boolean muteUser(long guildID, long userID, boolean isMuting) {
    GuildObject content = Globals.getGuildContent(guildID);
    IUser user = Globals.getClient().getUserByID(userID);
    IGuild guild = Globals.getClient().getGuildByID(guildID);
    IRole mutedRole = Globals.client.getRoleByID(content.config.getMutedRoleID());
    List<IRole> oldRoles = user.getRolesForGuild(guild);
    if (mutedRole != null) {
        roleManagement(Globals.getClient().getUserByID(userID), Globals.client.getGuildByID(guildID), mutedRole.getLongID(), isMuting);
        List<IRole> newRoles = user.getRolesForGuild(guild);
        Globals.getClient().getDispatcher().dispatch(new UserRoleUpdateEvent(guild, user, oldRoles, newRoles));
        return true;
    }
    return false;
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject) UserRoleUpdateEvent(sx.blah.discord.handle.impl.events.guild.member.UserRoleUpdateEvent)

Example 3 with GuildObject

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

the class TimerHandler method dailyMessageHandler.

private static void dailyMessageHandler(TimedEvent event) {
    ZonedDateTime timeNow = ZonedDateTime.now(ZoneOffset.UTC);
    DayOfWeek day = timeNow.getDayOfWeek();
    logger.info("Running Daily tasks for " + day);
    Random random = new Random();
    for (GuildObject task : Globals.getGuilds()) {
        GuildConfig guildconfig = task.config;
        // do decay
        GuildHandler.dailyTask(task);
        // reset offenders
        task.resetOffenders();
        // getToggles general channel
        IChannel generalChannel = task.getChannelByType(ChannelSetting.GENERAL);
        // do daily messages
        if (generalChannel != null && guildconfig.dailyMessage) {
            DailyMessage finalMessage;
            List<DailyMessage> messages;
            if (event != null && event.doSpecialMessages() && event.getMessagesDay(day).size() != 0) {
                messages = event.getMessagesDay(day);
            } else {
                messages = new ArrayList<>(Globals.getDailyMessages().getDailyMessages(day));
                messages.add(Globals.getDailyMessage(day));
            }
            int randomMessage = random.nextInt(messages.size());
            finalMessage = messages.get(randomMessage);
            task.config.setLastDailyMessage(finalMessage);
            CommandObject command = new CommandObject(task, generalChannel);
            RequestHandler.sendMessage(finalMessage.getContents(command), generalChannel);
        }
    }
}
Also used : CommandObject(com.github.vaerys.commands.CommandObject) DayOfWeek(java.time.DayOfWeek) GuildObject(com.github.vaerys.masterobjects.GuildObject) IChannel(sx.blah.discord.handle.obj.IChannel) ZonedDateTime(java.time.ZonedDateTime) GuildConfig(com.github.vaerys.pogos.GuildConfig)

Example 4 with GuildObject

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

the class AnnotationListener method updateVariables.

public static void updateVariables(IGuild guild) {
    long guildID = guild.getLongID();
    GuildObject guildObject = Globals.getGuildContent(guildID);
    guildObject.config.updateVariables(guild);
    guildObject.characters.updateVars(guild);
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject)

Example 5 with GuildObject

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

the class AnnotationListener method onUserJoinEvent.

@EventSubscriber
public void onUserJoinEvent(UserJoinEvent event) {
    GuildObject content = Globals.getGuildContent(event.getGuild().getLongID());
    UserObject user = new UserObject(event.getUser().getLongID(), content);
    if (content.config.welcomeMessages && !user.get().isBot()) {
        JoinHandler.sendWelcomeMessage(content, event, user);
    }
    if (content.config.checkNewUsers) {
        JoinHandler.checkNewUsers(content, event, user);
    }
    if (content.config.moduleJoinMessages && content.config.sendJoinMessages) {
        JoinHandler.customJoinMessages(content, event.getUser());
    }
    JoinHandler.autoReMute(event, content, user);
    if (!content.config.moduleLogging)
        return;
    LoggingHandler.doJoinLeaveLog(event, true);
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject) UserObject(com.github.vaerys.masterobjects.UserObject) EventSubscriber(sx.blah.discord.api.events.EventSubscriber)

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