Skip to content

Commit

Permalink
Switch getAsTag() with getName(), replaces UserName#0000 with UserName
Browse files Browse the repository at this point in the history
  • Loading branch information
KiriCattus committed Feb 3, 2024
1 parent 1c1cfff commit 2692976
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public final class VersionCommand {
final var id = matcher.group("id");
event.deferReply()
.addEmbeds(getMavenInfo(repo, group, id)
.setFooter("Requested by: " + event.getUser().getAsTag(), event.getUser().getAvatarUrl())
.setFooter("Requested by: " + event.getUser().getName(), event.getUser().getAvatarUrl())
.setTimestamp(Instant.now())
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected void execute(final CFCommandContext context, final CurseForgeManager m
setEmbedAuthor(embed);
final var user = TheCommander.getJDA().getUserById(arguments.get(0));
if (user != null) {
embed.setFooter("Requested by: " + user.getAsTag(), user.getAvatarUrl());
embed.setFooter("Requested by: " + user.getName(), user.getAvatarUrl());
}
if (arguments.size() > startingIndex + 1) {
arguments.subList(startingIndex + 1, Math.min(maximum, arguments.size()))
Expand Down Expand Up @@ -171,7 +171,7 @@ protected void execute(final CFCommandContext context, final CurseForgeManager m
final var embed = new EmbedBuilder()
.setTimestamp(Instant.now())
.setColor(Color.GREEN)
.setFooter("Requested by: " + context.getUser().getAsTag(), context.getUser().getAvatarUrl())
.setFooter("Requested by: " + context.getUser().getName(), context.getUser().getAvatarUrl())
.setTitle(mod.name(), mod.links().websiteUrl())
.setThumbnail(mod.logo().thumbnailUrl())
.setDescription(mod.summary())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected void execute(final SlashCommandEvent event) {
event.replyEmbeds(new EmbedBuilder().setTitle("Raw contents of " + trickName)
.setDescription(MarkdownUtil.codeblock(trick instanceof ScriptTrick ? "js" : null, trick.getRaw())).setColor(Color.GREEN)
.addField("Trick Names", String.join(" ", trick.getNames()), false)
.setTimestamp(Instant.now()).setFooter("Requested by: " + event.getUser().getAsTag(),
.setTimestamp(Instant.now()).setFooter("Requested by: " + event.getUser().getName(),
event.getUser().getAvatarUrl()).build()).addActionRow(DismissListener.createDismissButton(event)).queue();
}, () -> event.reply("This trick does not exist anymore!").setEphemeral(true).queue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static MessageEmbed reference(@NonNull final Message message, final Membe
final var embed = new EmbedBuilder().setTimestamp(message.getTimeCreated())
.setColor(Color.DARK_GRAY);
if (hasAuthor) {
embed.setAuthor(message.getAuthor().getAsTag(), msgLink, message.getAuthor().getEffectiveAvatarUrl());
embed.setAuthor(message.getAuthor().getName(), msgLink, message.getAuthor().getEffectiveAvatarUrl());
}
if (!message.getContentRaw().isBlank()) {
embed.appendDescription(MarkdownUtil.maskedLink("Reference ➤ ", msgLink))
Expand All @@ -87,7 +87,7 @@ public static MessageEmbed reference(@NonNull final Message message, final Membe
embed.appendDescription(MarkdownUtil.maskedLink("Jump to referenced message.", msgLink));
}
if (quoter.getIdLong() != message.getAuthor().getIdLong()) {
embed.setFooter(quoter.getUser().getAsTag() + " referenced", quoter.getEffectiveAvatarUrl());
embed.setFooter(quoter.getUser().getName() + " referenced", quoter.getEffectiveAvatarUrl());
}
if (!message.getAttachments().isEmpty()) {
embed.setImage(message.getAttachments().get(0).getUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public String resolveReference() {
User user = TheCommander.getJDA().getUserById(getSnowflakeData());
// If we have it...
if (user != null) {
return user.getAsTag();
return user.getName();
} else {
return String.valueOf(getSnowflakeData());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public static ScriptingContext createUser(User user, boolean canDm) {
context.set("avatarUrl", user.getAvatarUrl());
context.set("isBot", user.isBot());
context.set("hasPrivateChannel", user.hasPrivateChannel());
context.setFunction("asTag", args -> user.getAsTag());
context.setFunction("asTag", args -> user.getName());
context.setFunction("openPrivateChannel", args -> {
validateArgs(args, 0);
final var privateChannel = user.openPrivateChannel().complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void onGuildMemberJoin(@NotNull final GuildMemberJoinEvent event) {
final var embed = new EmbedBuilder()
.setColor(Color.GREEN)
.setTitle("User Joined")
.addField("User:", event.getMember().getUser().getAsTag(), true)
.addField("User:", event.getMember().getUser().getName(), true)
.setFooter("User ID: " + event.getMember().getId(), event.getMember().getEffectiveAvatarUrl())
.setTimestamp(Instant.now())
.build();
Expand All @@ -71,7 +71,7 @@ public void onGuildMemberRemove(@NotNull final GuildMemberRemoveEvent event) {
final var embed = new EmbedBuilder()
.setColor(Color.RED)
.setTitle("User Left")
.addField("User:", event.getUser().getAsTag(), true)
.addField("User:", event.getUser().getName(), true)
.addField("Roles", RoleEvents.mentionsOrEmpty(event.getMember().getRoles()), false)
.setFooter("User ID: " + event.getMember().getId(), event.getMember().getEffectiveAvatarUrl())
.setTimestamp(Instant.now())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void onBan(final User bannedUser, final User bannedBy, final AuditLogEntr
final var embed = new EmbedBuilder();
embed.setColor(Color.RED);
embed.setTitle("User Banned.");
embed.addField("**User:**", bannedUser.getAsTag(), true);
embed.addField("**User:**", bannedUser.getName(), true);
embed.addField("**Ban reason:**", reason, false);
embed.setFooter("User ID: " + bannedUser.getId(), bannedUser.getEffectiveAvatarUrl());
embed.setTimestamp(Instant.now());
Expand All @@ -139,7 +139,7 @@ public void onUnban(final User unBannedUser, final User bannedBy, final AuditLog
final var embed = new EmbedBuilder();
embed.setColor(Color.GREEN);
embed.setTitle("User Un-banned.");
embed.addField("**User:**", unBannedUser.getAsTag(), true);
embed.addField("**User:**", unBannedUser.getName(), true);
embed.setFooter("User ID: " + unBannedUser.getId(), unBannedUser.getEffectiveAvatarUrl());
embed.setTimestamp(Instant.now());

Expand All @@ -150,7 +150,7 @@ public void onNicknameUpdate(final User target, final User editor, final AuditLo
final var embed = new EmbedBuilder();
embed.setColor(Color.YELLOW);
embed.setTitle("Nickname Changed");
embed.addField("User:", target.getAsTag(), true);
embed.addField("User:", target.getName(), true);
embed.addField("Old Nickname:", wrapNicknameValue(nicknameChange.getOldValue()), true);
embed.addField("New Nickname:", wrapNicknameValue(nicknameChange.getNewValue()), true);
embed.setFooter("User ID: " + target.getId(), target.getEffectiveAvatarUrl());
Expand All @@ -166,15 +166,15 @@ private static String wrapNicknameValue(@Nullable String nicknameValue) {
public void onKick(final User kickedUser, final User kicker, final AuditLogEntry entry) {
final var embed = new EmbedBuilder();
if (kicker.isBot()) {
var botKickMessage = kickedUser.getAsTag() + " was kicked! Kick Reason: " + entry.getReason();
var botKickMessage = kickedUser.getName() + " was kicked! Kick Reason: " + entry.getReason();
log(entry.getGuild().getIdLong(), entry.getJDA(), botKickMessage, kicker);
} else {
final var reason = requireNonNullElse(entry.getReason(), "Reason for kick was not provided or could not be found, please contact "
+ "a member of staff for more information about this kick.");

embed.setColor(RUBY);
embed.setTitle("User Kicked");
embed.addField("**Name:**", kickedUser.getAsTag(), true);
embed.addField("**Name:**", kickedUser.getName(), true);
embed.addField("**Kick reason:**", reason, false);
embed.setFooter("User ID: " + kickedUser.getId(), kickedUser.getAvatarUrl());
embed.setTimestamp(Instant.now());
Expand All @@ -198,7 +198,7 @@ public void onTimeoutUpdate(final User user, final User moderator, final AuditLo

embed.setColor(LIGHT_SEA_GREEN);
embed.setTitle("User Timed Out");
embed.addField("**User:**", user.getAsTag(), true);
embed.addField("**User:**", user.getName(), true);
embed.addField("**Timeout End:**", TimeFormat.RELATIVE.format(newTimeoutEnd),
true);
embed.addField("**Reason:**", reason, false);
Expand All @@ -212,7 +212,7 @@ public void onTimeoutUpdate(final User user, final User moderator, final AuditLo

embed.setColor(Color.CYAN);
embed.setTitle("User Timeout Removed");
embed.addField("**User:**", user.getAsTag(), true);
embed.addField("**User:**", user.getName(), true);
embed.addField("**Old Timeout End:**", TimeFormat.RELATIVE.format(oldTimeoutEnd),
true);
embed.setFooter("User ID: " + user.getId(), user.getEffectiveAvatarUrl());
Expand All @@ -238,7 +238,7 @@ public void onWarnAdd(final WarningEvent.Add event) {
final var embed = new EmbedBuilder()
.setColor(Color.RED)
.setTitle("Warning Added")
.setDescription(user.getAsTag() + " has been given a warning.")
.setDescription(user.getName() + " has been given a warning.")
.addField("Warning Reason:", doc.reason(), false)
.addField("Warning ID:", doc.warnId(), false)
.setFooter("User ID: " + user.getId(), user.getEffectiveAvatarUrl())
Expand All @@ -259,7 +259,7 @@ public void onWarnClear(final WarningEvent.Clear event) {
final var embed = new EmbedBuilder()
.setColor(Color.GREEN)
.setTitle("Warning Removed")
.setDescription("One of the warnings of " + user.getAsTag() + " has been removed!")
.setDescription("One of the warnings of " + user.getName() + " has been removed!")
.setThumbnail(user.getAvatarUrl())
.addField("Old Warning:", warnDoc.reason(), false)
.setFooter("User ID: " + user.getId(), user.getEffectiveAvatarUrl())
Expand All @@ -279,7 +279,7 @@ public void onWarnClearAll(final WarningEvent.ClearAllWarns event) {
final var embed = new EmbedBuilder()
.setColor(java.awt.Color.GREEN)
.setTitle("All Warnings Removed")
.setDescription("All of ``" + user.getAsTag() + "``'s warnings have been removed!")
.setDescription("All of ``" + user.getName() + "``'s warnings have been removed!")
.setTimestamp(Instant.now())
.setFooter("User ID: " + user.getId(), user.getEffectiveAvatarUrl())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private static void buildAndSendMessage(AuditLogEntry entry, Member target, Stri

embed.setTitle("User Role(s) " + changeType)
.setColor(Color.YELLOW)
.addField("User:", target.getUser().getAsTag(), true)
.addField("User:", target.getUser().getName(), true)
.setFooter("User ID: " + target.getUser().getId(), target.getEffectiveAvatarUrl())
.setTimestamp(entry.getTimeCreated());

Expand All @@ -138,7 +138,7 @@ private static void buildAndSendMessage(AuditLogEntry entry, Member target, Stri
})
.queue(editor -> {
if (editor != null) {
embed.addField("Editor:", editor.getAsTag(), true);
embed.addField("Editor:", editor.getName(), true);
}

embed.addField("Previous Role(s):", mentionsOrEmpty(previousRoles), true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected void execute(final CommandEvent event) {
final String banReason;
if (!(args.length > 1)) {
banReason = "Reason for ban could not be found or was not provided, please contact "
+ event.getMember().getUser().getAsTag() + " - (" + event.getMember().getId() + ")";
+ event.getMember().getUser().getName() + " - (" + event.getMember().getId() + ")";
} else {
banReason = event.getArgs().substring(args[0].length() + 1);
}
Expand All @@ -98,7 +98,7 @@ protected void execute(final CommandEvent event) {
unit = TimeUnit.MINUTES;
}

final String auditReason = "Ban issued by " + event.getAuthor().getAsTag() + ": " + banReason;
final String auditReason = "Ban issued by " + event.getAuthor().getName() + ": " + banReason;
if (!event.getArgs().contains("-d")) {
event.getGuild().ban(member, 0, TimeUnit.DAYS).reason(auditReason).queue();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected void execute(final CommandEvent event) {
final String kickReason;
if (!mentioned && !(args.length > 1)) {
kickReason = "Reason for kick could not be found or was not provided, please contact "
+ author.getUser().getAsTag() + " - (" + author.getId() + ")";
+ author.getUser().getName() + " - (" + author.getId() + ")";
} else {
kickReason = mentioned ? event.getArgs() : event.getArgs().substring(args[0].length() + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void execute(final SlashCommandEvent event) {
return;
}

guild.removeTimeout(user).reason("Timeout removed at the request of " + event.getUser().getAsTag()).queue();
guild.removeTimeout(user).reason("Timeout removed at the request of " + event.getUser().getName()).queue();

final var muteEmbed = new EmbedBuilder().setColor(Color.DARK_GRAY)
.setTitle(user.getEffectiveName() + " has been un-muted!").setTimestamp(Instant.now())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void onAutoComplete(final CommandAutoCompleteInteractionEvent event) {
.limit(5)
.map(id -> {
final var targetMember = event.getJDA().getUserById(WarningCommand.<Long>withExtension(db -> db.getUser(id)));
return new Command.Choice(id + (targetMember == null ? "" : (" - " + targetMember.getAsTag())), id);
return new Command.Choice(id + (targetMember == null ? "" : (" - " + targetMember.getName())), id);
}).toList()).queue();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void onMessageReactionAdd(final MessageReactionAddEvent event) {

WEBHOOKS.getWebhook(logChannel)
.send(Utils.webhookMessage(builder.build())
.setUsername(messageAuthor.getAsTag())
.setUsername(messageAuthor.getName())
.setAvatarUrl(messageAuthor.getEffectiveAvatarUrl())
.build());
}
Expand Down Expand Up @@ -187,7 +187,7 @@ public void onMessageReactionAdd(final MessageReactionAddEvent event) {
.appendDescription(", and has been approved by moderators for deletion.");

final String approvingMods = signedOffStaff.stream()
.map(s -> "%s (%s, id `%s`)".formatted(s.getAsMention(), s.getUser().getAsTag(), s.getId()))
.map(s -> "%s (%s, id `%s`)".formatted(s.getAsMention(), s.getUser().getName(), s.getId()))
.collect(Collectors.joining("\n"));
builder.addField("Approving moderators", approvingMods, true);

Expand All @@ -199,7 +199,7 @@ public void onMessageReactionAdd(final MessageReactionAddEvent event) {
.send(Utils.webhookMessage(builder.build())
.setContent(message.getContentRaw())
.setAvatarUrl(messageAuthor.getEffectiveAvatarUrl())
.setUsername(messageAuthor.getAsTag())
.setUsername(messageAuthor.getName())
.build());
}

Expand Down

0 comments on commit 2692976

Please sign in to comment.