some transforms
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
f1791fac44
commit
4c788bc321
7 changed files with 16 additions and 13 deletions
|
@ -42,7 +42,7 @@ export async function* matchMultipleTextTypesOnMessage(
|
|||
}
|
||||
|
||||
if (trigger.match_visible_names) {
|
||||
yield ["visiblename", member.nickname || msg.data.author.username];
|
||||
yield ["visiblename", member.nickname || member.user.globalName || msg.data.author.username];
|
||||
}
|
||||
|
||||
if (trigger.match_usernames) {
|
||||
|
|
|
@ -68,10 +68,9 @@ export const ArchiveChannelCmd = channelArchiverCmd({
|
|||
|
||||
for (const message of messages.values()) {
|
||||
const ts = moment.utc(message.createdTimestamp).format("YYYY-MM-DD HH:mm:ss");
|
||||
let content = `[${ts}] [${message.author.id}] [${renderUsername(
|
||||
message.author.username,
|
||||
message.author.discriminator,
|
||||
)}]: ${message.content || "<no text content>"}`;
|
||||
let content = `[${ts}] [${message.author.id}] [${renderUsername(message.author)}]: ${
|
||||
message.content || "<no text content>"
|
||||
}`;
|
||||
|
||||
if (message.attachments.size) {
|
||||
if (args["attachment-channel"]) {
|
||||
|
|
|
@ -85,7 +85,7 @@ export async function getInviteInfoEmbed(
|
|||
embed.fields.push({
|
||||
name: preEmbedPadding + "Invite creator",
|
||||
value: trimLines(`
|
||||
Name: **${renderUsername(invite.inviter.username, invite.inviter.discriminator)}**
|
||||
Name: **${renderUsername(invite.inviter)}**
|
||||
ID: \`${invite.inviter.id}\`
|
||||
Mention: <@!${invite.inviter.id}>
|
||||
`),
|
||||
|
|
|
@ -71,7 +71,7 @@ export async function getMessageInfoEmbed(
|
|||
embed.fields.push({
|
||||
name: preEmbedPadding + "Author information",
|
||||
value: trimLines(`
|
||||
Name: **${renderUsername(message.author.username, message.author.discriminator)}**
|
||||
Name: **${renderUsername(message.author)}**
|
||||
ID: \`${message.author.id}\`
|
||||
Created: **<t:${Math.round(message.author.createdTimestamp / 1000)}:R>**
|
||||
${authorJoinedAtTS ? `Joined: **<t:${Math.round(authorJoinedAtTS / 1000)}:R>**` : ""}
|
||||
|
|
|
@ -43,7 +43,7 @@ export async function getUserInfoEmbed(
|
|||
const timeAndDate = pluginData.getPlugin(TimeAndDatePlugin);
|
||||
|
||||
embed.author = {
|
||||
name: `${user.bot ? "Bot" : "User"}: ${renderUsername(user.username, user.discriminator)}`,
|
||||
name: `${user.bot ? "Bot" : "User"}: ${renderUsername(user)}`,
|
||||
};
|
||||
|
||||
const avatarURL = user.displayAvatarURL();
|
||||
|
@ -72,9 +72,8 @@ export async function getUserInfoEmbed(
|
|||
}
|
||||
|
||||
const userInfoLines = [`ID: \`${user.id}\``, `Username: **${user.username}**`];
|
||||
if (user.discriminator !== "0") {
|
||||
userInfoLines.push(`Discriminator: **${user.discriminator}**`);
|
||||
}
|
||||
if (user.discriminator !== "0") userInfoLines.push(`Discriminator: **${user.discriminator}**`);
|
||||
if (user.globalName) userInfoLines.push(`Display Name: **${user.globalName}**`);
|
||||
userInfoLines.push(`Created: **<t:${Math.round(user.createdTimestamp / 1000)}:R>**`);
|
||||
userInfoLines.push(`Mention: <@!${user.id}>`);
|
||||
|
||||
|
|
|
@ -1603,8 +1603,11 @@ export function isTruthy<T>(value: T): value is Exclude<T, false | null | undefi
|
|||
|
||||
export const DBDateFormat = "YYYY-MM-DD HH:mm:ss";
|
||||
|
||||
export function renderUsername(username: string, discriminator: string): string {
|
||||
if (discriminator === "0") {
|
||||
export function renderUsername(username: User): string;
|
||||
export function renderUsername(username: string, discriminator?: string): string;
|
||||
export function renderUsername(username: string | User, discriminator?: string): string {
|
||||
if (username instanceof User) return username.tag;
|
||||
if (discriminator === "0" || discriminator === "0000") {
|
||||
return username;
|
||||
}
|
||||
return `${username}#${discriminator}`;
|
||||
|
|
|
@ -49,6 +49,7 @@ export class TemplateSafeUser extends TemplateSafeValueContainer {
|
|||
id: Snowflake | string;
|
||||
username: string;
|
||||
discriminator: string;
|
||||
globalName?: string;
|
||||
mention: string;
|
||||
tag: string;
|
||||
avatarURL?: string;
|
||||
|
@ -257,6 +258,7 @@ export function userToTemplateSafeUser(user: User | UnknownUser): TemplateSafeUs
|
|||
id: user.id,
|
||||
username: user.username,
|
||||
discriminator: user.discriminator,
|
||||
globalName: user.globalName,
|
||||
mention: `<@${user.id}>`,
|
||||
tag: user.tag,
|
||||
avatarURL: user.displayAvatarURL?.(),
|
||||
|
|
Loading…
Add table
Reference in a new issue