Search in sources :

Example 16 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project DiscordSailv2 by Vaerys-Dawn.

the class EnterComp method execute.

@Override
public String execute(String args, CommandObject command) {
    GuildConfig guildconfig = command.guild.config;
    IMessage message = command.message.get();
    IUser author = command.user.get();
    if (guildconfig.compEntries) {
        String fileName;
        String fileUrl;
        if (message.getAttachments().size() > 0) {
            List<IMessage.Attachment> attatchments = message.getAttachments();
            IMessage.Attachment a = attatchments.get(0);
            fileName = a.getFilename();
            fileUrl = a.getUrl();
        } else if (!args.isEmpty()) {
            fileName = author.getName() + "'s Entry";
            fileUrl = args;
        } else {
            return "> Missing a File or Image link to enter into the competition.";
        }
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy - HH:mm:ss");
        Calendar cal = Calendar.getInstance();
        command.guild.competition.newEntry(new CompObject(author.getDisplayName(command.guild.get()), author.getLongID(), fileName, fileUrl, dateFormat.format(cal.getTime())));
        return "> Thank you " + author.getDisplayName(command.guild.get()) + " For entering the Competition.";
    } else {
        return "> Competition Entries are closed.";
    }
}
Also used : GuildConfig(com.github.vaerys.pogos.GuildConfig) IMessage(sx.blah.discord.handle.obj.IMessage) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Calendar(java.util.Calendar) IUser(sx.blah.discord.handle.obj.IUser) CompObject(com.github.vaerys.objects.CompObject) SimpleDateFormat(java.text.SimpleDateFormat)

Example 17 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project DiscordSailv2 by Vaerys-Dawn.

the class UpdateRolePerms method execute.

@Override
public String execute(String args, CommandObject command) {
    List<IRole> parentRole = GuildHandler.getRolesByName(command.guild.get(), args);
    EnumSet parentPerms = command.guild.get().getEveryoneRole().getPermissions();
    ArrayList<String> permList = new ArrayList<>();
    IMessage workingMsg = RequestHandler.sendMessage("`Working...`", command.channel.get()).get();
    if (parentRole.size() != 0) {
        if (command.guild.config.isRoleCosmetic(parentRole.get(0).getLongID())) {
            parentPerms = parentRole.get(0).getPermissions();
        }
    }
    for (IRole r : command.guild.get().getRoles()) {
        if (command.guild.config.isRoleCosmetic(r.getLongID())) {
            if (!r.getPermissions().containsAll(parentPerms)) {
                EnumSet finalParentPerms = parentPerms;
                RequestBuffer.request(() -> r.changePermissions(finalParentPerms));
            }
        }
    }
    for (Object p : parentPerms.toArray()) {
        permList.add(p.toString());
    }
    RequestHandler.deleteMessage(workingMsg);
    return "> Cosmetic Roles Perms set to : " + Utility.listFormatter(permList, true);
}
Also used : IRole(sx.blah.discord.handle.obj.IRole) EnumSet(java.util.EnumSet) IMessage(sx.blah.discord.handle.obj.IMessage) ArrayList(java.util.ArrayList) CommandObject(com.github.vaerys.commands.CommandObject)

Example 18 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project DiscordSailv2 by Vaerys-Dawn.

the class ResetRuleCode method execute.

@Override
public String execute(String args, CommandObject command) {
    IMessage working = RequestHandler.sendMessage("`Working...`", command.channel).get();
    for (ProfileObject p : command.guild.users.profiles) {
        if (p.getSettings().size() != 0) {
            p.getSettings().remove(UserSetting.READ_RULES);
        }
    }
    for (IUser u : command.guild.getUsers()) {
        GuildHandler.checkUsersRoles(u.getLongID(), command.guild);
    }
    RequestHandler.deleteMessage(working);
    return "Done. The Rule code tag has been removed off all profiles.";
}
Also used : IMessage(sx.blah.discord.handle.obj.IMessage) IUser(sx.blah.discord.handle.obj.IUser) ProfileObject(com.github.vaerys.objects.ProfileObject)

Example 19 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project DiscordSailv2 by Vaerys-Dawn.

the class CheckPixelRoles method execute.

@Override
public String execute(String args, CommandObject command) {
    IMessage working = RequestHandler.sendMessage("`Working...`", command.channel.get()).get();
    for (IUser user : command.guild.getUsers()) {
        GuildHandler.checkUsersRoles(user.getLongID(), command.guild);
    }
    RequestHandler.deleteMessage(working);
    return "> Done.";
}
Also used : IMessage(sx.blah.discord.handle.obj.IMessage) IUser(sx.blah.discord.handle.obj.IUser)

Example 20 with IMessage

use of sx.blah.discord.handle.obj.IMessage in project DiscordSailv2 by Vaerys-Dawn.

the class Report method report.

public static String report(String args, CommandObject command, boolean isSilent) {
    List<IChannel> channels = command.guild.getChannelsByType(ChannelSetting.ADMIN);
    if (channels.size() != 0) {
        IChannel channel = channels.get(0);
        SplitFirstObject split = new SplitFirstObject(args);
        UserObject reported = Utility.getUser(command, split.getFirstWord(), false, false);
        if (reported == null) {
            return "> Cannot send report. Could not find user.";
        }
        if (reported.longID == command.user.longID) {
            return "> You can't report yourself.";
        }
        if (channel != null) {
            StringBuilder builder = new StringBuilder();
            IRole roleToMention = command.guild.getRoleByID(command.guild.config.getRoleToMentionID());
            if (roleToMention != null) {
                builder.append(roleToMention.mention() + "\n");
            }
            if (isSilent) {
                builder.append("**User Report - Silent**\n");
            } else {
                builder.append("**User Report**\n");
            }
            split.editRestReplace(split.getRest(), Utility.convertMentionToText(split.getRest()));
            String reason = split.getRest();
            if (split.getRest() == null) {
                reason = "No reason given.";
            }
            builder.append("Reporter: " + command.user.get().mention() + "\nReported: " + reported.get().mention() + "\nReason: `" + reason + "`");
            builder.append("\n" + command.channel.get().mention());
            IMessage message = RequestHandler.sendMessage(builder.toString(), channel).get();
            if (message == null) {
                return "> User report was not be sent. Looks like I can't send messages to " + channel.mention() + ".";
            } else {
                return "> User Report sent.";
            }
        }
        return "> Your report could not be sent as the server does not have an admin channel set up at this time.";
    } else {
        return "> Your report could not be sent as the server does not have an admin channel set up at this time.";
    }
}
Also used : IChannel(sx.blah.discord.handle.obj.IChannel) IRole(sx.blah.discord.handle.obj.IRole) IMessage(sx.blah.discord.handle.obj.IMessage) UserObject(com.github.vaerys.masterobjects.UserObject) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Aggregations

IMessage (sx.blah.discord.handle.obj.IMessage)46 IUser (sx.blah.discord.handle.obj.IUser)10 EmbedBuilder (sx.blah.discord.util.EmbedBuilder)9 EventSubscriber (sx.blah.discord.api.events.EventSubscriber)6 IChannel (sx.blah.discord.handle.obj.IChannel)6 ProfileObject (com.github.vaerys.objects.ProfileObject)5 UserObject (com.github.vaerys.masterobjects.UserObject)4 ArrayList (java.util.ArrayList)4 DiscordException (sx.blah.discord.util.DiscordException)4 Announcement (com.cloudcraftgaming.discal.api.object.announcement.Announcement)3 PreEvent (com.cloudcraftgaming.discal.api.object.event.PreEvent)3 CommandObject (com.github.vaerys.commands.CommandObject)3 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)3 GitHubImage (io.github.spugn.Sargo.Utilities.GitHubImage)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 RateLimitException (sx.blah.discord.util.RateLimitException)3 PreCalendar (com.cloudcraftgaming.discal.api.object.calendar.PreCalendar)2 TrackLikes (com.github.vaerys.objects.TrackLikes)2