Search in sources :

Example 6 with GuildConfig

use of com.github.vaerys.pogos.GuildConfig in project DiscordSailv2 by Vaerys-Dawn.

the class SetupHandler method setSetupStage.

public static void setSetupStage(CommandObject command, SetupStage stage) {
    GuildConfig config = command.guild.config;
    logger.debug("Setting Stage to " + stage.toString());
    config.setupStage = stage;
    config.setupUser = (stage == SetupStage.SETUP_UNSET) ? -1 : command.user.longID;
    // send the title and step text to channel
    if (stage != SetupStage.SETUP_UNSET && stage != SetupStage.SETUP_COMPLETE) {
        // command.setChannel(command.user.getDmChannel());
        // get stage:
        SetupHandler currentStage = configStages.get(config.setupStage);
        String titleText = "**__Step " + (stage.ordinal()) + ": " + currentStage.title() + "__**";
        RequestHandler.sendMessage(titleText, command.user.getDmChannel());
        // it is expected that you send the message yourself
        currentStage.stepText(command);
    }
}
Also used : GuildConfig(com.github.vaerys.pogos.GuildConfig)

Example 7 with GuildConfig

use of com.github.vaerys.pogos.GuildConfig in project DiscordSailv2 by Vaerys-Dawn.

the class SpamHandler method checkForInvites.

public static boolean checkForInvites(CommandObject command) {
    GuildConfig guildconfig = command.guild.config;
    if (!guildconfig.denyInvites) {
        return false;
    }
    IMessage message = command.message.get();
    IGuild guild = command.guild.get();
    IUser author = command.user.get();
    List<String> inviteformats = new ArrayList<String>() {

        {
            add("discord.gg");
            add("discordapp.com/Invite/");
        }
    };
    if (GuildHandler.testForPerms(command, Permissions.MANAGE_MESSAGES))
        return false;
    boolean inviteFound = false;
    boolean shouldDelete = false;
    ProfileObject object = command.user.getProfile(command.guild);
    boolean userSettingDenied = false;
    if (object != null) {
        userSettingDenied = object.getSettings().contains(UserSetting.DENY_INVITES);
    }
    for (String s : inviteformats) {
        if (message.toString().toLowerCase().contains(s.toLowerCase())) {
            inviteFound = true;
        }
    }
    boolean isTrusted = guildconfig.testIsTrusted(author, guild);
    if (userSettingDenied || !isTrusted) {
        shouldDelete = true;
    }
    if (inviteFound && shouldDelete) {
        String response;
        if (userSettingDenied) {
            response = "> " + command.user.mention() + ", you do not have permission to post Instant Invites.";
        } else {
            response = "> " + command.user.mention() + ", please do not post Instant Invites.";
        }
        RequestHandler.deleteMessage(message);
        command.guild.sendDebugLog(command, "INVITE_REMOVAL", "REMOVED", message.getContent());
        RequestHandler.sendMessage(response, command.channel.get());
        return true;
    }
    return false;
}
Also used : GuildConfig(com.github.vaerys.pogos.GuildConfig) ArrayList(java.util.ArrayList) ProfileObject(com.github.vaerys.objects.ProfileObject)

Aggregations

GuildConfig (com.github.vaerys.pogos.GuildConfig)7 SetupStage (com.github.vaerys.handlers.SetupHandler.SetupStage)2 CommandObject (com.github.vaerys.commands.CommandObject)1 GuildObject (com.github.vaerys.masterobjects.GuildObject)1 CompObject (com.github.vaerys.objects.CompObject)1 OffenderObject (com.github.vaerys.objects.OffenderObject)1 ProfileObject (com.github.vaerys.objects.ProfileObject)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 DayOfWeek (java.time.DayOfWeek)1 ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 UserRoleUpdateEvent (sx.blah.discord.handle.impl.events.guild.member.UserRoleUpdateEvent)1 IChannel (sx.blah.discord.handle.obj.IChannel)1 IMessage (sx.blah.discord.handle.obj.IMessage)1 IUser (sx.blah.discord.handle.obj.IUser)1