utility.linvite: add boosts, invite expiry and welcome screen

This commit is contained in:
Cynthia Foxwell 2023-04-09 11:22:27 -06:00
parent 7b289b0863
commit de999f1858

View file

@ -292,7 +292,7 @@ lookupinvite.callback = async function (msg, line) {
try {
invite = await hf.bot.requestHandler.request(
"GET",
`/invites/${line}?with_counts=1`
`/invites/${line}?with_counts=true&with_expiration=true`
);
} catch (err) {
bail = true;
@ -328,11 +328,38 @@ lookupinvite.callback = async function (msg, line) {
value: `**${invite.channel.name}** (${invite.channel.id})`,
inline: true,
},
{
name: "Boosts",
value: invite.guild.premium_subscription_count ?? 0,
inline: true,
},
{
name: "Expires",
value:
invite.expires_at == null
? "Never"
: `<t:${Math.floor(new Date(invite.expires_at).getTime / 1000)}>`,
inline: true,
},
{
name: "Member Count",
value: `${STATUS_ICONS.online}${invite.approximate_presence_count} online\t\t${STATUS_ICONS.offline}${invite.approximate_member_count} members`,
inline: false,
},
invite.welcome_screen && {
name: "Welcome Screen",
value: `"${
invite.welcome_screen.description
}"\n${invite.welcome_screen.welcome_channels.map(
(c) =>
`${
c.emoji_id
? `[:${c.emoji_name}:](${EMOTE_BASE}${c.emoji_id}.webp)`
: c.emoji_name
} ${c.description} \`(${c.channel_id})\``
)}`,
inline: false,
},
{
name: "Features",
value:
@ -348,7 +375,7 @@ lookupinvite.callback = async function (msg, line) {
: "None",
inline: false,
},
],
].filter((x) => !!x),
thumbnail: {
url:
invite.guild.icon &&
@ -761,9 +788,9 @@ presence.callback = async function (msg, line) {
if (activity.emoji) {
if (activity.emoji.id) {
const url = `https://cdn.discordapp.com/emojis/${
activity.emoji.id
}.${activity.emoji.animated ? "gif" : "png"}`;
const url = `${EMOTE_BASE}${activity.emoji.id}.${
activity.emoji.animated ? "gif" : "png"
}`;
embed.author = {
url,
icon_url: url,