Skip to content

Commit

Permalink
Allow LookupCmd to show creation date for guilds without invite/widget
Browse files Browse the repository at this point in the history
  • Loading branch information
MichailiK committed Dec 12, 2020
1 parent a716fc5 commit a1ad532
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/main/java/com/jagrosh/vortex/commands/tools/LookupCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,25 @@ private void lookupGuild(String inviteCode, CommandEvent event)

private Message constructMessage(Invite invite, Widget widget)
{
String gname;
long gid;
int users;
String gname = "Unknown Guild";
long gid = 0L;
int users = -1;
if(invite == null)
{
if(widget == null)
return new MessageBuilder().append(Constants.ERROR + " No users, guilds, or invites found.").build();
else if (!widget.isAvailable())
return new MessageBuilder().append(Constants.SUCCESS + " Guild with ID `" + widget.getId() + "` found; no further information found.").build();

gid = widget.getIdLong();
gname = widget.getName();
users = widget.getMembers().size();
if(widget.isAvailable())
{
gname = widget.getName();
users = widget.getMembers().size();
}
}
else
{
Invite.Guild g = invite.getGuild();
if(g == null)
{
gid = 0L;
gname = "Unknown Guild";
users = 0;
}
else
if(g != null)
{
gid = g.getIdLong();
gname = g.getName();
Expand All @@ -227,8 +223,8 @@ else if (!widget.isAvailable())

String text = GUILD_EMOJI + " Information about **" + gname + "**:";
EmbedBuilder eb = new EmbedBuilder();
eb.appendDescription(LINESTART + "ID: **" + gid + "**"
+ "\n" + LINESTART + "Creation: **" + TimeUtil.getTimeCreated(gid).format(DateTimeFormatter.RFC_1123_DATE_TIME) + "**"
eb.appendDescription(LINESTART + "ID: " + (gid == 0 ? "N/A" : "**"+gid+"**")
+ "\n" + LINESTART + "Creation: " + (gid == 0 ? "N/A" : "**"+TimeUtil.getTimeCreated(gid).format(DateTimeFormatter.RFC_1123_DATE_TIME)+"**")
+ "\n" + LINESTART + "Users: " + (users == -1 ? "N/A" : "**" + users + "** online")
+ (widget != null && widget.isAvailable() ? "\n" + LINESTART + "Channels: **" + widget.getVoiceChannels().size() + "** voice" : ""));
if(invite != null)
Expand Down

0 comments on commit a1ad532

Please sign in to comment.