use of sx.blah.discord.handle.obj.IUser in project DiscordSailv2 by Vaerys-Dawn.
the class Respond method execute.
@Override
public String execute(String args, CommandObject command) {
SplitFirstObject response = new SplitFirstObject(args);
IUser recipient = command.client.get().getUserByID(Utility.stringLong(response.getFirstWord()));
return sendDM(response.getRest(), command, recipient, command.user.username + ": ");
}
use of sx.blah.discord.handle.obj.IUser in project DiscordSailv2 by Vaerys-Dawn.
the class Server method execute.
@Override
public String execute(String args, CommandObject command) {
for (ServerObject s : command.guild.servers.getServers()) {
if (s.getName().equalsIgnoreCase(args)) {
IUser user = command.guild.getUserByID(s.getCreatorID());
boolean isGuildUser = true;
if (user == null) {
user = command.client.get().fetchUser(s.getCreatorID());
isGuildUser = false;
}
StringBuilder builder = new StringBuilder();
builder.append("**" + s.getName() + "**\n");
builder.append("**IP:** " + s.getServerIP() + " **Port:** " + s.getServerPort() + "\n");
if (isGuildUser) {
builder.append("**Listing Creator:** " + user.getDisplayName(command.guild.get()) + "\n");
} else {
builder.append("**Listing Creator:** " + user.getName() + "#" + user.getDiscriminator() + "\n");
}
builder.append(s.getServerDesc());
command.user.sendDm(builder.toString());
return "> Server info has been sent to your DMs";
}
}
return "> Server with that name not found.";
}
use of sx.blah.discord.handle.obj.IUser in project DiscordSailv2 by Vaerys-Dawn.
the class MentionCommand method isCall.
@Override
public boolean isCall(String args, CommandObject command) {
if (command.guild.client.bot == null) {
command.guild.sendDebugLog(command, "MENTION_COMMAND", "BOT_NULL", command.message.getContent());
return false;
}
SplitFirstObject mention = new SplitFirstObject(args);
if (mention.getRest() == null) {
return false;
}
List<IUser> users = command.message.getMentions();
IUser bot = command.client.bot.get();
if (bot == null || !users.contains(bot)) {
return false;
}
SplitFirstObject call = new SplitFirstObject(mention.getRest());
for (String s : names) {
String regex = "^(<@|<@!)" + command.client.bot.longID + "> " + s.toLowerCase();
String toMatch = mention.getFirstWord() + " " + call.getFirstWord().toLowerCase();
Matcher matcher = Pattern.compile(regex).matcher(toMatch);
if (matcher.matches()) {
return true;
}
}
return false;
}
use of sx.blah.discord.handle.obj.IUser in project DiscordSailv2 by Vaerys-Dawn.
the class GetCCData method execute.
@Override
public String execute(String args, CommandObject command) {
for (CCommandObject c : command.guild.customCommands.getCommandList()) {
if (c.getName().equalsIgnoreCase(args)) {
StringBuilder content = new StringBuilder("Command Name: \"" + c.getName() + "\"");
IUser createdBy = command.guild.getUserByID(c.getUserID());
if (createdBy == null)
createdBy = command.client.get().fetchUser(c.getUserID());
if (createdBy == null)
content.append("\nCreated by: \"null\"");
else
content.append("\nCreated by: \"" + createdBy.getName() + "#" + createdBy.getDiscriminator() + "\"");
content.append("\nTimes run: \"" + c.getTimesRun() + "\"");
content.append("\nContents: \"" + c.getContents(false) + "\"");
String filePath = Constants.DIRECTORY_TEMP + command.message.longID + ".txt";
FileHandler.writeToFile(filePath, content.toString(), false);
RequestHandler.sendFile("> Here is the raw data for Custom Command: **" + c.getName() + "**", new File(filePath), command.channel.get());
try {
Thread.sleep(4000);
new File(filePath).delete();
} catch (InterruptedException e) {
Utility.sendStack(e);
}
return "";
}
}
return "> Custom command " + args + " could not be found.";
// return command.customCommands.sendCCasJSON(command.channelSID, args);
}
use of sx.blah.discord.handle.obj.IUser in project DiscordSailv2 by Vaerys-Dawn.
the class InfoCC method execute.
@Override
public String execute(String args, CommandObject command) {
CCommandObject customCommand = command.guild.customCommands.getCommand(args);
if (customCommand == null) {
return Constants.ERROR_CC_NOT_FOUND;
}
StringBuilder builder = new StringBuilder();
XEmbedBuilder embedBuilder = new XEmbedBuilder(command);
String title = "> Here is the information for command: **" + customCommand.getName() + "**\n";
IUser createdBy = command.guild.getUserByID(customCommand.getUserID());
if (createdBy == null)
createdBy = command.client.get().fetchUser(customCommand.getUserID());
if (createdBy == null)
builder.append("Creator: **Null**\n");
else
builder.append("Creator: **@" + createdBy.getName() + "#" + createdBy.getDiscriminator() + "**\n");
builder.append("Time Run: **" + customCommand.getTimesRun() + "**\n");
builder.append("Is Locked: **" + customCommand.isLocked() + "**\n");
builder.append("Is ShitPost: **" + customCommand.isShitPost() + "**");
embedBuilder.appendField(title, builder.toString(), false);
RequestHandler.sendEmbedMessage("", embedBuilder, command.channel.get());
return null;
}
Aggregations