Skip to content
This repository has been archived by the owner on Jun 15, 2018. It is now read-only.

Commit

Permalink
bumped version number
Browse files Browse the repository at this point in the history
added some colors
fixed quotes
can setgame twitch
  • Loading branch information
jagrosh committed Feb 18, 2017
1 parent a23e518 commit 294b8c6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/jselfbot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
* @author John Grosh (jagrosh)
*/
public class Constants {
public static final String VERSION = "0.5";
public static final String VERSION = "0.6";
public static final String FAILURE = "\u274C";
}
2 changes: 1 addition & 1 deletion src/jselfbot/commands/EmbedCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected void execute(String args, MessageReceivedEvent event) {
+ "`{thumbnail:`IMAGE`}`\n"
+ "`{field:`NAME`|`VALUE`|`true/false`}` or `{field:`NAME`|`VALUE`}` *can include multiple fields\n"
+ "`{image:`IMAGE`}`\n"
+ "`{color:`#HEX`}`\n"
+ "`{color:`#HEX`}` or `{color:name}`\n"
+ "`{footer:`TEXT`|`IMAGE`}` or `{footer:`TEXT`}`\n"
+ "`{timestamp:`ISO`}` or `{timestamp}` *current time if nothing included\n"
+ "Any remaining text goes into the description", event);
Expand Down
13 changes: 11 additions & 2 deletions src/jselfbot/commands/GameCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ protected void execute(String args, MessageReceivedEvent event) {
else
{
try {
event.getJDA().getPresence().setGame(Game.of(args));
result = "Game set to `"+args+"`. Note that it will appear to everyone else but will not show in your own client.";
Game game;
if(args.startsWith("twitch"))
{
String[] parts = args.substring(6).trim().split("\\s+",2);
args = parts[1];
game = Game.of(args, "http://twitch.tv/"+parts[0]);
}
else
game = Game.of(args);
event.getJDA().getPresence().setGame(game);
result = "Game set to "+(game.getUrl()==null ? "Playing": "Streaming")+" `"+args+"`. Note that it will appear to everyone else but will not show in your own client.";
} catch(Exception e) {
result = "Game could not be set to `"+args+"`";
}
Expand Down
9 changes: 5 additions & 4 deletions src/jselfbot/commands/QuoteCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected void execute(String args, MessageReceivedEvent event) {
channel = event.getChannel();
try
{
String foot = channel.equals(event.getChannel()) ? "" : " in #"+channel.getName();
channel.getHistoryAround(messageId, 2).queue(
mh -> {
if(mh.getRetrievedHistory().isEmpty())
Expand All @@ -92,7 +93,7 @@ protected void execute(String args, MessageReceivedEvent event) {
Message msg = mh.getRetrievedHistory().size()==1 || mh.getRetrievedHistory().size()==2 ? mh.getRetrievedHistory().get(0) : mh.getRetrievedHistory().get(1);
EmbedBuilder builder = new EmbedBuilder();
builder.setAuthor(msg.getAuthor().getName()+" #"+msg.getAuthor().getDiscriminator(), null,
msg.getAuthor().getAvatarUrl()==null ? msg.getAuthor().getDefaultAvatarUrl() : msg.getAuthor().getAvatarUrl());
msg.getAuthor().getEffectiveAvatarUrl());
if(msg.getGuild()!=null)
{
Member member = msg.getGuild().getMemberById(msg.getAuthor().getId());
Expand All @@ -103,12 +104,12 @@ protected void execute(String args, MessageReceivedEvent event) {
builder.setImage(msg.getAttachments().get(0).getUrl());
if(msg.isEdited())
{
builder.setFooter("Edited", null);
builder.setFooter("Edited"+foot, null);
builder.setTimestamp(msg.getEditedTime());
}
else
{
builder.setFooter("Sent", null);
builder.setFooter("Sent"+foot, null);
builder.setTimestamp(msg.getCreationTime());
}
builder.setDescription(msg.getRawContent());
Expand All @@ -118,7 +119,7 @@ protected void execute(String args, MessageReceivedEvent event) {
}
catch(Exception e)
{
tempReply("Could not retrieve history", event);
tempReply("Could not retrieve history: "+e, event);
}
}

Expand Down
25 changes: 24 additions & 1 deletion src/jselfbot/entities/JagTagMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,30 @@ public static Collection<Method> getMethods()

new Method("color", (env, in) -> {
EmbedBuilder eb = env.get("builder");
eb.setColor(Color.decode(in[0]));
switch(in[0].toLowerCase()) {
//standard
case "red": eb.setColor(Color.RED); break;
case "orange": eb.setColor(Color.ORANGE); break;
case "yellow": eb.setColor(Color.YELLOW); break;
case "green": eb.setColor(Color.GREEN); break;
case "cyan": eb.setColor(Color.CYAN); break;
case "blue": eb.setColor(Color.BLUE); break;
case "magenta": eb.setColor(Color.MAGENTA); break;
case "pink": eb.setColor(Color.PINK); break;
case "black": eb.setColor(Color.BLACK); break;
case "dark_gray":
case "dark_grey": eb.setColor(Color.DARK_GRAY); break;
case "gray":
case "grey": eb.setColor(Color.GRAY); break;
case "light_gray":
case "light_grey": eb.setColor(Color.LIGHT_GRAY); break;
case "white": eb.setColor(Color.WHITE); break;
//discord
case "blurple": eb.setColor(Color.decode("#7289DA")); break;
case "greyple": eb.setColor(Color.decode("#99AAB5")); break;
case "darktheme": eb.setColor(Color.decode("#2C2F33")); break;
default: eb.setColor(Color.decode(in[0]));
}
return "";}),

new Method("footer", (env, in) -> {
Expand Down

0 comments on commit 294b8c6

Please sign in to comment.