+ Added formattable benchmark for returns and adjusted to vaguely fuzzy-search
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package dataStructures;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class KittyEmbed
|
||||
{
|
||||
public String title = null;
|
||||
public Color color = null;
|
||||
public String footerText = null;
|
||||
public String authorText = null;
|
||||
public String authorLink = null;
|
||||
public String authorImage = null;
|
||||
public String descriptionText = null;
|
||||
|
||||
public KittyEmbed()
|
||||
{
|
||||
this.title = "Untitled";
|
||||
}
|
||||
}
|
||||
@@ -5,26 +5,52 @@ import java.io.InputStream;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.events.message.guild.*;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
// NOTE(wisp): This isn't constructed with the factory at this time, mostly
|
||||
// because we need it to handle all the response queue behavior and everything
|
||||
// internally. So long as commands aren't exposed to the GuildMessageReceivedEvent
|
||||
// then we should be fine.
|
||||
// This isn't constructed with the factory at this time, mostly because we need it
|
||||
// to handle all the response queue behavior and everything internally. So long as
|
||||
// commands aren't exposed to the GuildMessageReceivedEvent then we should be fine.
|
||||
public class Response
|
||||
{
|
||||
// Variables
|
||||
private GuildMessageReceivedEvent event;
|
||||
private JDA kitty;
|
||||
private final int discordMessageMax = 2000;
|
||||
private final int kittyMessageMax = 1950;
|
||||
|
||||
// Constructor
|
||||
public Response(GuildMessageReceivedEvent event, JDA kitty)
|
||||
{
|
||||
this.event = event;
|
||||
this.kitty = kitty;
|
||||
}
|
||||
|
||||
// Builds a nicely formatted embedded message based on information provided
|
||||
public void CallEmbed(KittyEmbed embedInfo)
|
||||
{
|
||||
EmbedBuilder embed = new EmbedBuilder();
|
||||
|
||||
if(embedInfo.title != null)
|
||||
embed.setTitle(embedInfo.title);
|
||||
|
||||
if(embedInfo.color != null)
|
||||
embed.setColor(embedInfo.color);
|
||||
|
||||
if(embedInfo.descriptionText != null)
|
||||
embed.setDescription(embedInfo.descriptionText);
|
||||
|
||||
if(embedInfo.footerText != null)
|
||||
embed.setFooter(embedInfo.footerText, null);
|
||||
|
||||
if(embedInfo.authorImage != null || embedInfo.authorLink != null || embedInfo.authorText != null)
|
||||
embed.setAuthor(embedInfo.authorText, embedInfo.authorLink, embedInfo.authorImage);
|
||||
|
||||
event.getChannel().sendMessage(embed.build()).queue();
|
||||
}
|
||||
|
||||
// Queues a standard text-based message response to the channel that issued the command.
|
||||
public void Call(String toRespondWith)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Response, "Sending response: " + toRespondWith);
|
||||
@@ -38,6 +64,7 @@ public class Response
|
||||
}
|
||||
}
|
||||
|
||||
// Queues a standard text-based message response to the specified channel.
|
||||
public void CallToChannel(String toRespondWith, String channelID)
|
||||
{
|
||||
TextChannel channel;
|
||||
@@ -52,6 +79,7 @@ public class Response
|
||||
}
|
||||
}
|
||||
|
||||
// Immediately dispatches the message to the channel that issued the command.
|
||||
public void CallImmediate(String toRespondWith)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Response, "Sending immediate response: " + toRespondWith);
|
||||
@@ -65,13 +93,14 @@ public class Response
|
||||
}
|
||||
}
|
||||
|
||||
// This is for responding with a file rather than a String
|
||||
// Queues a file response to the channel that issued the command.
|
||||
public void CallFile(File toRespondWith, String extension)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Response, "Sending file response");
|
||||
event.getChannel().sendFile(toRespondWith, "return." + extension).queue();
|
||||
}
|
||||
|
||||
// Queues an input stream response to the channel that issued the command.
|
||||
public void CallInput(InputStream in, String extension)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Response, "Sending input stream response");
|
||||
|
||||
Reference in New Issue
Block a user