utility.lookupinvite: group dm and friend invite support
This commit is contained in:
parent
f4f2015fb3
commit
8a1f5b9fdd
|
@ -180,7 +180,8 @@ avatar.callback = async function(msg, line, [user], { server, guild }) {
|
||||||
return "`--server/--guild` can only be used within guilds.";
|
return "`--server/--guild` can only be used within guilds.";
|
||||||
} else {
|
} else {
|
||||||
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
||||||
const url = `${ICON_BASE}${guild.id}/${guild.icon}.${guild.icon.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024"
|
const url = `${ICON_BASE}${guild.id}/${guild.icon}.${
|
||||||
|
guild.icon.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024"
|
||||||
}`;
|
}`;
|
||||||
return {
|
return {
|
||||||
embeds: [
|
embeds: [
|
||||||
|
@ -321,7 +322,8 @@ banner.callback = async function(msg, line, [user], { server, guild }) {
|
||||||
|
|
||||||
if (!guild.banner) return "This guild does not have a banner.";
|
if (!guild.banner) return "This guild does not have a banner.";
|
||||||
|
|
||||||
const url = `${BANNER_BASE}${guild.id}/${guild.banner}.${guild.banner.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024"
|
const url = `${BANNER_BASE}${guild.id}/${guild.banner}.${
|
||||||
|
guild.banner.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024"
|
||||||
}`;
|
}`;
|
||||||
return {
|
return {
|
||||||
embeds: [
|
embeds: [
|
||||||
|
@ -356,7 +358,8 @@ banner.callback = async function(msg, line, [user], { server, guild }) {
|
||||||
|
|
||||||
if (!userObj.banner) return "This user does not have a banner.";
|
if (!userObj.banner) return "This user does not have a banner.";
|
||||||
|
|
||||||
const url = `${BANNER_BASE}${userObj.id}/${userObj.banner}.${userObj.banner.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024"
|
const url = `${BANNER_BASE}${userObj.id}/${userObj.banner}.${
|
||||||
|
userObj.banner.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024"
|
||||||
}`;
|
}`;
|
||||||
return {
|
return {
|
||||||
embeds: [
|
embeds: [
|
||||||
|
@ -415,7 +418,30 @@ lookupinvite.callback = async function(msg, line) {
|
||||||
const embed = {
|
const embed = {
|
||||||
title: `Invite Info: \`${invite.code}\``,
|
title: `Invite Info: \`${invite.code}\``,
|
||||||
description: invite.description,
|
description: invite.description,
|
||||||
fields: [
|
fields: [],
|
||||||
|
thumbnail: {
|
||||||
|
url:
|
||||||
|
invite.guild.icon &&
|
||||||
|
`${ICON_BASE}${invite.guild.id}/${invite.guild.icon}.${
|
||||||
|
invite.guild.icon.startsWith("a_")
|
||||||
|
? "gif?size=1024&_=.gif"
|
||||||
|
: "png?size=1024"
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const expires = {
|
||||||
|
name: "Expires",
|
||||||
|
value:
|
||||||
|
invite.expires_at == null
|
||||||
|
? "Never"
|
||||||
|
: `<t:${Math.floor(new Date(invite.expires_at).getTime() / 1000)}>`,
|
||||||
|
inline: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (invite.type == 0) {
|
||||||
|
embed.fields.push(
|
||||||
|
...[
|
||||||
{
|
{
|
||||||
name: "Guild",
|
name: "Guild",
|
||||||
value: `**${invite.guild.name}** (${invite.guild.id})`,
|
value: `**${invite.guild.name}** (${invite.guild.id})`,
|
||||||
|
@ -436,23 +462,16 @@ lookupinvite.callback = async function(msg, line) {
|
||||||
value: invite.guild.premium_subscription_count ?? 0,
|
value: invite.guild.premium_subscription_count ?? 0,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
expires,
|
||||||
name: "Expires",
|
|
||||||
value:
|
|
||||||
invite.expires_at == null
|
|
||||||
? "Never"
|
|
||||||
: `<t:${Math.floor(
|
|
||||||
new Date(invite.expires_at).getTime() / 1000
|
|
||||||
)}>`,
|
|
||||||
inline: true,
|
|
||||||
},
|
|
||||||
invite.guild.welcome_screen && {
|
invite.guild.welcome_screen && {
|
||||||
name: "Welcome Screen",
|
name: "Welcome Screen",
|
||||||
value: `"${invite.guild.welcome_screen.description
|
value: `"${
|
||||||
|
invite.guild.welcome_screen.description
|
||||||
}"\n${invite.guild.welcome_screen.welcome_channels
|
}"\n${invite.guild.welcome_screen.welcome_channels
|
||||||
.map(
|
.map(
|
||||||
(c) =>
|
(c) =>
|
||||||
`${c.emoji_id
|
`${
|
||||||
|
c.emoji_id
|
||||||
? `[:${c.emoji_name}:](${EMOTE_BASE}${c.emoji_id}.webp)`
|
? `[:${c.emoji_name}:](${EMOTE_BASE}${c.emoji_id}.webp)`
|
||||||
: c.emoji_name
|
: c.emoji_name
|
||||||
} ${c.description} \`(${c.channel_id})\``
|
} ${c.description} \`(${c.channel_id})\``
|
||||||
|
@ -475,42 +494,63 @@ lookupinvite.callback = async function(msg, line) {
|
||||||
: "None",
|
: "None",
|
||||||
inline: false,
|
inline: false,
|
||||||
},
|
},
|
||||||
].filter((x) => !!x),
|
].filter((x) => !!x)
|
||||||
thumbnail: {
|
);
|
||||||
url:
|
} else if (invite.type == 1) {
|
||||||
invite.guild.icon &&
|
embed.title += " (Group DM)";
|
||||||
`${ICON_BASE}${invite.guild.id}/${invite.guild.icon}.${invite.guild.icon.startsWith("a_")
|
embed.fields.push(
|
||||||
? "gif?size=1024&_=.gif"
|
{
|
||||||
: "png?size=1024"
|
name: "Channel",
|
||||||
}`,
|
value: `**${invite.channel.name}** (${invite.channel.id})`,
|
||||||
|
inline: true,
|
||||||
},
|
},
|
||||||
};
|
expires
|
||||||
|
);
|
||||||
|
} else if (invite.type == 2) {
|
||||||
|
embed.title += " (Friend)";
|
||||||
|
embed.fields.push(expires);
|
||||||
|
}
|
||||||
|
|
||||||
if (invite.inviter) {
|
if (invite.inviter) {
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "Inviter",
|
name: "Inviter",
|
||||||
value: `**${invite.inviter.username}#${invite.inviter.discriminator}** (${invite.inviter.id})`,
|
value: `**${
|
||||||
|
invite.inviter.discriminator && invite.inviter.discriminator != "0"
|
||||||
|
? `${invite.inviter.username}#${invite.inviter.discriminator}`
|
||||||
|
: `@${invite.inviter.username}`
|
||||||
|
}** (${invite.inviter.id})`,
|
||||||
inline: true,
|
inline: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invite.guild.icon || invite.guild.splash || invite.guild.banner) {
|
if (
|
||||||
|
invite.guild &&
|
||||||
|
(invite.guild.icon || invite.guild.splash || invite.guild.banner)
|
||||||
|
) {
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "\u200b",
|
name: "\u200b",
|
||||||
value: `${invite.guild.icon
|
value: `${
|
||||||
? `[Icon](${ICON_BASE}${invite.guild.id}/${invite.guild.icon}.${invite.guild.icon.startsWith("a_")
|
invite.guild.icon
|
||||||
|
? `[Icon](${ICON_BASE}${invite.guild.id}/${invite.guild.icon}.${
|
||||||
|
invite.guild.icon.startsWith("a_")
|
||||||
? "gif?size=1024"
|
? "gif?size=1024"
|
||||||
: "png?size=1024"
|
: "png?size=1024"
|
||||||
})`
|
})`
|
||||||
: ""
|
: ""
|
||||||
}${invite.guild.splash
|
}${
|
||||||
? `${invite.guild.icon ? " | " : ""}[Splash](${SPLASH_BASE}${invite.guild.id
|
invite.guild.splash
|
||||||
|
? `${invite.guild.icon ? " | " : ""}[Splash](${SPLASH_BASE}${
|
||||||
|
invite.guild.id
|
||||||
}/${invite.guild.splash}.png?size=2048)`
|
}/${invite.guild.splash}.png?size=2048)`
|
||||||
: ""
|
: ""
|
||||||
}${invite.guild.banner
|
}${
|
||||||
? `${invite.guild.icon || invite.guild.splash ? " | " : ""
|
invite.guild.banner
|
||||||
}[Banner](${BANNER_BASE}${invite.guild.id}/${invite.guild.banner
|
? `${
|
||||||
}.${invite.guild.banner.startsWith("a_")
|
invite.guild.icon || invite.guild.splash ? " | " : ""
|
||||||
|
}[Banner](${BANNER_BASE}${invite.guild.id}/${
|
||||||
|
invite.guild.banner
|
||||||
|
}.${
|
||||||
|
invite.guild.banner.startsWith("a_")
|
||||||
? "gif?size=1024"
|
? "gif?size=1024"
|
||||||
: "png?size=1024"
|
: "png?size=1024"
|
||||||
})`
|
})`
|
||||||
|
@ -520,7 +560,7 @@ lookupinvite.callback = async function(msg, line) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invite.guild.splash) {
|
if (invite.guild?.splash) {
|
||||||
embed.image = {
|
embed.image = {
|
||||||
url: `${SPLASH_BASE}${invite.guild.id}/${invite.guild.splash}.png?size=256`,
|
url: `${SPLASH_BASE}${invite.guild.id}/${invite.guild.splash}.png?size=256`,
|
||||||
};
|
};
|
||||||
|
@ -605,13 +645,15 @@ flagdump.callback = async function(msg, line, [numOrMention], { id, list }) {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return "User not cached.";
|
return "User not cached.";
|
||||||
} else {
|
} else {
|
||||||
return `\`${user.username}#${user.discriminator
|
return `\`${user.username}#${
|
||||||
|
user.discriminator
|
||||||
}\`'s public flags:\n\`\`\`${flagFromInt(user.publicFlags)}\`\`\``;
|
}\`'s public flags:\n\`\`\`${flagFromInt(user.publicFlags)}\`\`\``;
|
||||||
}
|
}
|
||||||
} else if (!isNaN(num)) {
|
} else if (!isNaN(num)) {
|
||||||
return `\`\`\`\n${flagFromInt(num)}\`\`\``;
|
return `\`\`\`\n${flagFromInt(num)}\`\`\``;
|
||||||
} else {
|
} else {
|
||||||
return `\`${msg.author.username}#${msg.author.discriminator
|
return `\`${msg.author.username}#${
|
||||||
|
msg.author.discriminator
|
||||||
}\`'s public flags:\n\`\`\`${flagFromInt(msg.author.publicFlags)}\`\`\``;
|
}\`'s public flags:\n\`\`\`${flagFromInt(msg.author.publicFlags)}\`\`\``;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -788,7 +830,8 @@ presence.callback = async function(msg, line) {
|
||||||
|
|
||||||
if (activity.emoji) {
|
if (activity.emoji) {
|
||||||
if (activity.emoji.id) {
|
if (activity.emoji.id) {
|
||||||
const url = `${EMOTE_BASE}${activity.emoji.id}.${activity.emoji.animated ? "gif" : "png"
|
const url = `${EMOTE_BASE}${activity.emoji.id}.${
|
||||||
|
activity.emoji.animated ? "gif" : "png"
|
||||||
}`;
|
}`;
|
||||||
embed.author = {
|
embed.author = {
|
||||||
url,
|
url,
|
||||||
|
@ -985,7 +1028,8 @@ presence.callback = async function(msg, line) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: `Presence for **${target.username}#${target.discriminator
|
content: `Presence for **${target.username}#${
|
||||||
|
target.discriminator
|
||||||
}**: ${icons.trim()}`,
|
}**: ${icons.trim()}`,
|
||||||
embeds,
|
embeds,
|
||||||
files,
|
files,
|
||||||
|
|
Loading…
Reference in New Issue