Update !info styles to match !server and !invite
This commit is contained in:
parent
ae1b749169
commit
16a85ed9a9
1 changed files with 32 additions and 30 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { Message, GuildTextableChannel, EmbedOptions } from "eris";
|
import { Message, GuildTextableChannel, EmbedOptions } from "eris";
|
||||||
import { PluginData } from "knub";
|
import { PluginData } from "knub";
|
||||||
import { UtilityPluginType } from "../types";
|
import { UtilityPluginType } from "../types";
|
||||||
import { UnknownUser, trimLines, embedPadding, resolveMember, resolveUser } from "src/utils";
|
import { UnknownUser, trimLines, embedPadding, resolveMember, resolveUser, preEmbedPadding } from "src/utils";
|
||||||
import moment from "moment-timezone";
|
import moment from "moment-timezone";
|
||||||
import { CaseTypes } from "src/data/CaseTypes";
|
import { CaseTypes } from "src/data/CaseTypes";
|
||||||
import humanizeDuration from "humanize-duration";
|
import humanizeDuration from "humanize-duration";
|
||||||
|
@ -22,21 +22,25 @@ export async function getUserInfoEmbed(
|
||||||
fields: [],
|
fields: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
embed.author = {
|
||||||
|
name: `User: ${user.username}#${user.discriminator}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
const avatarURL = user.avatarURL || user.defaultAvatarURL;
|
||||||
|
embed.author.icon_url = avatarURL;
|
||||||
|
|
||||||
const createdAt = moment(user.createdAt);
|
const createdAt = moment(user.createdAt);
|
||||||
const accountAge = humanizeDuration(moment().valueOf() - user.createdAt, {
|
const accountAge = humanizeDuration(moment().valueOf() - user.createdAt, {
|
||||||
largest: 2,
|
largest: 2,
|
||||||
round: true,
|
round: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
embed.title = `${user.username}#${user.discriminator}`;
|
|
||||||
embed.thumbnail = { url: user.avatarURL };
|
|
||||||
|
|
||||||
if (compact) {
|
if (compact) {
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "User information",
|
name: preEmbedPadding + "User information",
|
||||||
value: trimLines(`
|
value: trimLines(`
|
||||||
Profile: <@!${user.id}>
|
Profile: <@!${user.id}>
|
||||||
Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
|
Created: **${accountAge} ago** (\`${createdAt.format("MMM D, YYYY")}\`)
|
||||||
`),
|
`),
|
||||||
});
|
});
|
||||||
if (member) {
|
if (member) {
|
||||||
|
@ -45,11 +49,11 @@ export async function getUserInfoEmbed(
|
||||||
largest: 2,
|
largest: 2,
|
||||||
round: true,
|
round: true,
|
||||||
});
|
});
|
||||||
embed.fields[0].value += `\nJoined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**`;
|
embed.fields[0].value += `\nJoined: **${joinAge} ago** (\`${joinedAt.format("MMM D, YYYY")}\`)`;
|
||||||
} else {
|
} else {
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "!! USER IS NOT ON THE SERVER !!",
|
name: preEmbedPadding + "!! NOTE !!",
|
||||||
value: embedPadding,
|
value: "User is not on the server",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,13 +61,13 @@ export async function getUserInfoEmbed(
|
||||||
}
|
}
|
||||||
|
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "User information",
|
name: preEmbedPadding + "User information",
|
||||||
value:
|
value: trimLines(`
|
||||||
trimLines(`
|
Name: **${user.username}#${user.discriminator}**
|
||||||
ID: **${user.id}**
|
ID: \`${user.id}\`
|
||||||
Profile: <@!${user.id}>
|
Created: **${accountAge} ago** (\`${createdAt.format("MMM D, YYYY [at] H:mm [UTC]")}\`)
|
||||||
Created: **${accountAge} ago (${createdAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
|
Mention: <@!${user.id}>
|
||||||
`) + embedPadding,
|
`),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (member) {
|
if (member) {
|
||||||
|
@ -75,12 +79,11 @@ export async function getUserInfoEmbed(
|
||||||
const roles = member.roles.map(id => pluginData.guild.roles.get(id)).filter(r => !!r);
|
const roles = member.roles.map(id => pluginData.guild.roles.get(id)).filter(r => !!r);
|
||||||
|
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "Member information",
|
name: preEmbedPadding + "Member information",
|
||||||
value:
|
value: trimLines(`
|
||||||
trimLines(`
|
Joined: **${joinAge} ago** (\`${joinedAt.format("MMM D, YYYY [at] H:mm [UTC]")}\`)
|
||||||
Joined: **${joinAge} ago (${joinedAt.format("YYYY-MM-DD[T]HH:mm:ss")})**
|
${roles.length > 0 ? "Roles: `" + roles.map(r => r.name).join("`, `") + "`" : ""}
|
||||||
${roles.length > 0 ? "Roles: " + roles.map(r => r.name).join(", ") : ""}
|
`),
|
||||||
`) + embedPadding,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const voiceChannel = member.voiceState.channelID
|
const voiceChannel = member.voiceState.channelID
|
||||||
|
@ -88,19 +91,18 @@ export async function getUserInfoEmbed(
|
||||||
: null;
|
: null;
|
||||||
if (voiceChannel || member.voiceState.mute || member.voiceState.deaf) {
|
if (voiceChannel || member.voiceState.mute || member.voiceState.deaf) {
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "Voice information",
|
name: preEmbedPadding + "Voice information",
|
||||||
value:
|
value: trimLines(`
|
||||||
trimLines(`
|
|
||||||
${voiceChannel ? `Current voice channel: **${voiceChannel ? voiceChannel.name : "None"}**` : ""}
|
${voiceChannel ? `Current voice channel: **${voiceChannel ? voiceChannel.name : "None"}**` : ""}
|
||||||
${member.voiceState.mute ? "Server voice muted: **Yes**" : ""}
|
${member.voiceState.mute ? "Server voice muted: **Yes**" : ""}
|
||||||
${member.voiceState.deaf ? "Server voice deafened: **Yes**" : ""}
|
${member.voiceState.deaf ? "Server voice deafened: **Yes**" : ""}
|
||||||
`) + embedPadding,
|
`),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "!! USER IS NOT ON THE SERVER !!",
|
name: preEmbedPadding + "!! NOTE !!",
|
||||||
value: embedPadding,
|
value: "User is not on the server",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const cases = (await pluginData.state.cases.getByUserId(user.id)).filter(c => !c.is_hidden);
|
const cases = (await pluginData.state.cases.getByUserId(user.id)).filter(c => !c.is_hidden);
|
||||||
|
@ -111,13 +113,13 @@ export async function getUserInfoEmbed(
|
||||||
});
|
});
|
||||||
|
|
||||||
const caseSummary = cases.slice(0, 3).map(c => {
|
const caseSummary = cases.slice(0, 3).map(c => {
|
||||||
return `${CaseTypes[c.type]} (#${c.case_number})`;
|
return `${CaseTypes[c.type]} (\`#${c.case_number}\`)`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const summaryText = cases.length > 3 ? "Last 3 cases" : "Summary";
|
const summaryText = cases.length > 3 ? "Last 3 cases" : "Summary";
|
||||||
|
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "Cases",
|
name: preEmbedPadding + "Cases",
|
||||||
value: trimLines(`
|
value: trimLines(`
|
||||||
Total cases: **${cases.length}**
|
Total cases: **${cases.length}**
|
||||||
${summaryText}: ${caseSummary.join(", ")}
|
${summaryText}: ${caseSummary.join(", ")}
|
||||||
|
|
Loading…
Add table
Reference in a new issue