use of sx.blah.discord.handle.obj.IMessage in project S-argo by Expugn.
the class CharacterScout method displayAndSave.
/**
* Displays the scout results to the channel where the command was
* requested and save the results to the user file afterwards. If
* the results fail to display for any reason then the user file
* is not saved.
*/
void displayAndSave() {
ScoutMasterParser smp = new ScoutMasterParser();
if (!SIMPLE_MESSAGE) {
scoutMenu.withAuthorName(SELECTED_BANNER.getBannerName());
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED)
scoutMenu.appendField("- Scout Result -", characterString, false);
scoutMenu.withDesc(smp.getQuote());
scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
scoutMenu.withColor(244, 233, 167);
scoutMenu.withThumbnail(smp.getImage(highestRarity));
scoutMenu.withFooterIcon(new GitHubImage("images/System/Memory_Diamond_Icon.png").getURL());
scoutMenu.withFooterText((CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left");
LOGGER.debug("Displaying Scout Result...");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED)
display = CHANNEL.sendFile(scoutMenu.build(), new File(tempUserDirectory + "/results.png"));
else
display = CHANNEL.sendMessage(scoutMenu.build());
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
} else {
simpleMessage += "**" + SELECTED_BANNER.getBannerName() + "**" + "\n";
setupScoutMenu();
simpleMessage += smp.getQuote() + "\n";
if (!generateImage || IMAGE_DISABLED) {
simpleMessage += "**- Scout Result -**" + "\n";
simpleMessage += characterString;
}
simpleMessage += (CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + USER.getMemoryDiamonds() + " Memory Diamonds Left";
LOGGER.debug("Displaying Scout Result...");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED) {
display = CHANNEL.sendFile(simpleMessage, new File(tempUserDirectory + "/results.png"));
} else {
display = CHANNEL.sendMessage(simpleMessage);
}
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
}
LOGGER.debug("Saving User Data...");
USER.saveData();
deleteTempDirectory();
}
use of sx.blah.discord.handle.obj.IMessage in project S-argo by Expugn.
the class TicketScout method displayAndSave.
/**
* Displays the scout results to the channel where the command
* was requested and save the results to the user file afterwards.
* If the results fail to display for any reason then the user file
* is not saved.
*/
void displayAndSave() {
if (!SIMPLE_MESSAGE) {
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED)
scoutMenu.appendField("- Weapon Result -", itemString, false);
scoutMenu.withAuthorIcon(new GitHubImage("images/System/Scout_Icon.png").getURL());
scoutMenu.withColor(255, 255, 255);
scoutMenu.withFooterIcon(new GitHubImage("images/System/Memory_Diamond_Icon.png").getURL());
scoutMenu.withFooterText((CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + userTotalScouts + " Total Ticket Scouts");
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED)
display = CHANNEL.sendFile(scoutMenu.build(), new File(tempUserDirectory + "/results.png"));
else
display = CHANNEL.sendMessage(scoutMenu.build());
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
} else {
setupScoutMenu();
if (!generateImage || IMAGE_DISABLED) {
simpleMessage += "**- Weapon Result -**" + "\n";
simpleMessage += itemString;
}
simpleMessage += (CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getName() + "#" + CHANNEL.getGuild().getUserByID(Long.parseLong(DISCORD_ID)).getDiscriminator()) + " | " + userTotalScouts + " Total Ticket Scouts";
IMessage display = null;
try {
if (generateImage && !IMAGE_DISABLED) {
display = CHANNEL.sendFile(simpleMessage, new File(tempUserDirectory + "/results.png"));
} else {
display = CHANNEL.sendMessage(simpleMessage);
}
} catch (FileNotFoundException e) {
CHANNEL.sendMessage(new WarningMessage("FAILED TO GENERATE IMAGE", "Unable to display scout result.").get().build());
display.delete();
deleteTempDirectory();
return;
} catch (RateLimitException e) {
EmbedBuilder rateLimited = new WarningMessage("RATE LIMIT EXCEPTION", "Slow down on the requests!").get();
try {
display.edit(rateLimited.build());
} catch (NullPointerException a) {
// DO SOMETHING
}
deleteTempDirectory();
return;
}
}
USER.upgradeExchangeSwords();
USER.saveData();
deleteTempDirectory();
}
use of sx.blah.discord.handle.obj.IMessage in project DisCal-Discord-Bot by NovaFox161.
the class DevCommand method moduleReload.
private void moduleReload(MessageReceivedEvent event) {
IMessage msg = Message.sendMessage("Reloading DisCal! This may take a moment!", event);
for (IShard s : msg.getClient().getShards()) {
s.logout();
s.login();
}
Message.sendMessage("DisCal successfully reloaded!", event);
}
use of sx.blah.discord.handle.obj.IMessage in project DisCal-Discord-Bot by NovaFox161.
the class DevCommand method moduleEval.
@SuppressWarnings("all")
private void moduleEval(MessageReceivedEvent event) {
IGuild guild = event.getGuild();
IUser user = event.getAuthor();
IMessage message = event.getMessage();
IDiscordClient client = event.getClient();
IChannel channel = event.getChannel();
String input = message.getContent().substring(message.getContent().indexOf("eval") + 5).replaceAll("`", "");
Object o = null;
factory.put("guild", guild);
factory.put("channel", channel);
factory.put("user", user);
factory.put("message", message);
factory.put("command", this);
factory.put("client", client);
factory.put("builder", new EmbedBuilder());
factory.put("cUser", client.getOurUser());
try {
o = factory.eval(input);
} catch (Exception ex) {
EmbedBuilder em = new EmbedBuilder();
em.withAuthorIcon(guild.getIconURL());
em.withAuthorName("Error");
em.withDesc(ex.getMessage());
em.withFooterText("Eval failed");
em.withColor(56, 138, 237);
Message.sendMessage(em.build(), channel);
return;
}
EmbedBuilder em = new EmbedBuilder();
em.withAuthorIcon(guild.getIconURL());
em.withAuthorName("Success!");
em.withColor(56, 138, 237);
em.withTitle("Evaluation output.");
em.withDesc(o == null ? "No output, object is null" : o.toString());
em.appendField("Input", "```java\n" + input + "\n```", false);
em.withFooterText("Eval successful!");
Message.sendMessage(em.build(), channel);
}
use of sx.blah.discord.handle.obj.IMessage in project DisCal-Discord-Bot by NovaFox161.
the class AnnouncementCreator method init.
// Functionals
/**
* Initiates the creator for the guild involved.
* @param e The event received upon init.
* @return A new Announcement.
*/
public Announcement init(MessageReceivedEvent e, GuildSettings settings) {
if (!hasAnnouncement(e.getGuild().getLongID())) {
Announcement a = new Announcement(e.getGuild().getLongID());
a.setAnnouncementChannelId(e.getChannel().getStringID());
if (PermissionChecker.botHasMessageManagePerms(e)) {
IMessage msg = Message.sendMessage(AnnouncementMessageFormatter.getFormatAnnouncementEmbed(a, settings), MessageManager.getMessage("Creator.Announcement.Create.Init", settings), e);
a.setCreatorMessage(msg);
} else {
Message.sendMessage(MessageManager.getMessage("Creator.Notif.MANAGE_MESSAGES", settings), e);
}
announcements.add(a);
return a;
}
return getAnnouncement(e.getGuild().getLongID());
}
Aggregations