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.";
}
}
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);
}
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.";
}
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.";
}
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.";
}
}
Aggregations