guildinfo: bootleg profiles support
This commit is contained in:
parent
ffb47a7c28
commit
58183ab07a
2 changed files with 58 additions and 22 deletions
|
@ -72,7 +72,27 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
id = snowflake;
|
id = snowflake;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const clan = await hf.bot.requestHandler.request("GET", APIEndpoints.CLAN(snowflake), true);
|
let clan = await hf.bot.requestHandler.request("GET", APIEndpoints.CLAN(snowflake), true);
|
||||||
|
if (!clan) {
|
||||||
|
if (guild.profile) {
|
||||||
|
clan = guild.profile;
|
||||||
|
} else {
|
||||||
|
const verif = await hf.bot.requestHandler.request(
|
||||||
|
"GET",
|
||||||
|
`${APIEndpoints.GUILD_MEMBER_VERIFICATION(snowflake)}?with_guild=true`,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
if (verif?.profile) {
|
||||||
|
clan = verif.profile;
|
||||||
|
} else if (guild.vanityURL) {
|
||||||
|
const invite = await hf.bot.requestHandler.request(
|
||||||
|
"GET",
|
||||||
|
`${APIEndpoints.INVITE(guild.vanityURL)}?with_counts=true&with_expiration=true`
|
||||||
|
);
|
||||||
|
if (invite?.profile) clan = invite.profile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (clan) {
|
if (clan) {
|
||||||
const images = [];
|
const images = [];
|
||||||
|
@ -99,20 +119,34 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
clan.wildcard_descriptors = clan.wildcard_descriptors.filter((x) => x != "");
|
if (clan.wildcard_descriptors) clan.wildcard_descriptors = clan.wildcard_descriptors.filter((x) => x != "");
|
||||||
|
|
||||||
const termLines = [];
|
const termLines = [];
|
||||||
let currentTerm = "";
|
let currentTerm = "";
|
||||||
for (const index in clan.search_terms) {
|
if (clan.search_terms) {
|
||||||
const term = clan.search_terms[index];
|
for (const index in clan.search_terms) {
|
||||||
const formattedTerm = `\`\u2004${term.replaceAll(" ", "\u2005")}\u2004\``;
|
const term = clan.search_terms[index];
|
||||||
if (currentTerm.length + 1 + formattedTerm.length > 56) {
|
const formattedTerm = `\`\u2004${term.replaceAll(" ", "\u2005")}\u2004\``;
|
||||||
termLines.push(currentTerm);
|
if (currentTerm.length + 1 + formattedTerm.length > 56) {
|
||||||
currentTerm = formattedTerm;
|
termLines.push(currentTerm);
|
||||||
} else {
|
currentTerm = formattedTerm;
|
||||||
currentTerm += "\u2004" + formattedTerm;
|
} else {
|
||||||
|
currentTerm += "\u2004" + formattedTerm;
|
||||||
|
}
|
||||||
|
if (index == clan.search_terms.length - 1) termLines.push(currentTerm);
|
||||||
|
}
|
||||||
|
} else if (clan.traits) {
|
||||||
|
for (const index in clan.traits) {
|
||||||
|
const term = clan.traits[index];
|
||||||
|
const formattedTerm = `:${term.emoji_name}:\`\u2004${term.label.replaceAll(" ", "\u2005")}\u2004\``;
|
||||||
|
if (currentTerm.length + 1 + formattedTerm.length > 56) {
|
||||||
|
termLines.push(currentTerm);
|
||||||
|
currentTerm = formattedTerm;
|
||||||
|
} else {
|
||||||
|
currentTerm += "\u2004" + formattedTerm;
|
||||||
|
}
|
||||||
|
if (index == clan.search_terms.length - 1) termLines.push(currentTerm);
|
||||||
}
|
}
|
||||||
if (index == clan.search_terms.length - 1) termLines.push(currentTerm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let gameLines = "";
|
let gameLines = "";
|
||||||
|
@ -140,8 +174,8 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
value: clan.member_count,
|
value: clan.member_count,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
clan.search_terms.length > 0 && {
|
termLines.length > 0 && {
|
||||||
name: "Interests/Topics/Traits",
|
name: "Traits",
|
||||||
value: termLines.join("\n"),
|
value: termLines.join("\n"),
|
||||||
inline: false,
|
inline: false,
|
||||||
},
|
},
|
||||||
|
@ -155,14 +189,16 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
value: gameLines2,
|
value: gameLines2,
|
||||||
inline: false,
|
inline: false,
|
||||||
},
|
},
|
||||||
{
|
clan.badge_color_primary && {
|
||||||
name: "Badge Colors",
|
name: "Badge Colors",
|
||||||
value: `${clan.badge_color_primary}, ${clan.badge_color_secondary}`,
|
value: `${clan.badge_color_primary}, ${clan.badge_color_secondary}`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
clan.brand_color_primary && {
|
||||||
name: "Banner/Brand Colors",
|
name: "Banner/Brand Colors",
|
||||||
value: `${clan.brand_color_primary}, ${clan.brand_color_secondary}`,
|
value: `${clan.brand_color_primary}${
|
||||||
|
clan.brand_color_secondary ? `, ${clan.brand_color_secondary}` : ""
|
||||||
|
}`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
].filter((x) => !!x),
|
].filter((x) => !!x),
|
||||||
|
@ -526,7 +562,7 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
|
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "Member Count",
|
name: "Member Count",
|
||||||
value: `${Icons.online}${guildObj.approximate_presence_count} online\t\t${Icons.offline}${guildObj.approximate_member_count} members`,
|
value: `${Icons.online}${guildObj.approximate_presence_count} online\u3000\u3000${Icons.offline}${guildObj.approximate_member_count} members`,
|
||||||
inline: false,
|
inline: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -564,9 +600,8 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
if (guild.instant_invite) {
|
if (guild.instant_invite) {
|
||||||
invite = await hf.bot.requestHandler.request(
|
invite = await hf.bot.requestHandler.request(
|
||||||
"GET",
|
"GET",
|
||||||
`/invites/${guild.instant_invite.replace(
|
`${APIEndpoints.INVITE(
|
||||||
/(https?:\/\/)?(canary\.|ptb\.)?discord(\.gg|(app)?.com\/invite)\//,
|
guild.instant_invite.replace(/(https?:\/\/)?(canary\.|ptb\.)?discord(\.gg|(app)?.com\/invite)\//, "")
|
||||||
""
|
|
||||||
)}?with_counts=true&with_expiration=true`
|
)}?with_counts=true&with_expiration=true`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -595,7 +630,7 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
|
|
||||||
embed.fields.push({
|
embed.fields.push({
|
||||||
name: "Member Count",
|
name: "Member Count",
|
||||||
value: `${Icons.online}${invite.approximate_presence_count} online\t\t${Icons.offline}${invite.approximate_member_count} members`,
|
value: `${Icons.online}${invite.approximate_presence_count} online\u3000\u3000${Icons.offline}${invite.approximate_member_count} members`,
|
||||||
inline: false,
|
inline: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,8 @@ async function getGuild(id, noLocal = false) {
|
||||||
`${APIEndpoints.GUILD_MEMBER_VERIFICATION(id)}?with_guild=true`,
|
`${APIEndpoints.GUILD_MEMBER_VERIFICATION(id)}?with_guild=true`,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
if (verification?.guild) return {source: "verification", data: verification.guild};
|
if (verification?.guild)
|
||||||
|
return {source: "verification", data: {...verification.guild, profile: verification.profile}};
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue