2021-06-02 00:31:39 +00:00
|
|
|
const Command = require("../lib/command.js");
|
2021-06-02 00:32:30 +00:00
|
|
|
const CATEGORY = "utility";
|
2021-06-02 00:31:39 +00:00
|
|
|
|
|
|
|
const ICON_BASE = "https://cdn.discordapp.com/icons/";
|
|
|
|
const AVATAR_BASE = "https://cdn.discordapp.com/avatars/";
|
2021-06-02 00:58:39 +00:00
|
|
|
const SPLASH_BASE = "https://cdn.discordapp.com/splashes/";
|
|
|
|
const BANNER_BASE = "https://cdn.discordapp.com/banners/";
|
2021-08-12 03:31:56 +00:00
|
|
|
const EMOTE_BASE = "https://cdn.discordapp.com/emojis/";
|
2021-06-02 00:58:39 +00:00
|
|
|
|
|
|
|
const STATUS_ICONS = {
|
|
|
|
online: "<:online:493173082421461002>",
|
|
|
|
idle: "<:idle:493173082006093836>",
|
|
|
|
dnd: "<:dnd:493173082261815307>",
|
|
|
|
offline: "<:offline:493173082253426688>",
|
|
|
|
};
|
2021-06-02 00:31:39 +00:00
|
|
|
|
2021-08-12 03:31:56 +00:00
|
|
|
const EMOJI_SETS = {
|
|
|
|
blobs: {
|
|
|
|
prefix:
|
|
|
|
"https://cdn.jsdelivr.net/gh/googlefonts/noto-emoji@e456654119cc3a5f9bebb7bbd00512456f983d2d/svg/emoji_u",
|
|
|
|
sep: "_",
|
|
|
|
suffix: ".svg",
|
|
|
|
},
|
|
|
|
noto: {
|
2022-10-23 01:22:03 +00:00
|
|
|
prefix: "https://gitcdn.xyz/repo/googlefonts/noto-emoji/master/svg/emoji_u",
|
2021-08-12 03:31:56 +00:00
|
|
|
sep: "_",
|
|
|
|
suffix: ".svg",
|
|
|
|
},
|
|
|
|
twemoji: {
|
|
|
|
prefix: "https://twemoji.maxcdn.com/v/latest/svg/",
|
|
|
|
sep: "-",
|
|
|
|
suffix: ".svg",
|
|
|
|
},
|
|
|
|
mustd: {
|
|
|
|
prefix:
|
|
|
|
"https://cdn.jsdelivr.net/gh/Mstrodl/mutant-standard-mirror@0435227d9d8c0d6a346c8ae4c12b08a5cdc37041/emoji/",
|
|
|
|
sep: "-",
|
|
|
|
suffix: ".svg",
|
|
|
|
},
|
|
|
|
apple: {
|
|
|
|
prefix: "https://intrnl.github.io/assetsEmoji/AppleColor/emoji_u",
|
|
|
|
sep: "_",
|
|
|
|
suffix: ".png",
|
|
|
|
},
|
|
|
|
facebook: {
|
|
|
|
prefix: "https://intrnl.github.io/assetsEmoji/facebook/emoji_u",
|
|
|
|
sep: "_",
|
|
|
|
suffix: ".png",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
EMOJI_SETS["noto-old"] = EMOJI_SETS.blobs;
|
|
|
|
EMOJI_SETS.mutant = EMOJI_SETS.mustd;
|
|
|
|
EMOJI_SETS.mutstd = EMOJI_SETS.mustd;
|
|
|
|
EMOJI_SETS.ms = EMOJI_SETS.mustd;
|
|
|
|
EMOJI_SETS.twitter = EMOJI_SETS.twemoji;
|
|
|
|
EMOJI_SETS.fb = EMOJI_SETS.facebook;
|
|
|
|
|
2021-08-12 03:33:58 +00:00
|
|
|
const CUSTOM_EMOTE_REGEX = /<(?:\u200b|&)?(a)?:(\w+):(\d+)>/;
|
2021-08-12 03:31:56 +00:00
|
|
|
|
|
|
|
const sharp = require("sharp");
|
|
|
|
|
2022-10-10 19:13:02 +00:00
|
|
|
const {hastebin, lookupUser, formatTime} = require("../lib/utils.js");
|
2021-08-12 03:31:56 +00:00
|
|
|
const {getNamesFromString} = require("../lib/unicode.js");
|
2021-06-02 00:31:39 +00:00
|
|
|
|
|
|
|
const avatar = new Command("avatar");
|
|
|
|
avatar.category = CATEGORY;
|
|
|
|
avatar.helpText = "Get avatar of a user";
|
|
|
|
avatar.usage = "<user>";
|
2022-11-30 01:15:41 +00:00
|
|
|
avatar.callback = async function (msg, line, [user], {server, guild}) {
|
|
|
|
if (server || guild) {
|
2021-08-30 18:01:33 +00:00
|
|
|
if (!msg.guildID) {
|
2021-06-02 00:31:39 +00:00
|
|
|
return "`--server/--guild` can only be used within guilds.";
|
|
|
|
} else {
|
2021-08-30 18:01:33 +00:00
|
|
|
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"
|
2021-06-02 00:31:39 +00:00
|
|
|
}`;
|
|
|
|
return {
|
2021-08-30 02:04:26 +00:00
|
|
|
embeds: [
|
|
|
|
{
|
|
|
|
title: "Server Icon",
|
2021-06-02 00:31:39 +00:00
|
|
|
url,
|
2021-08-30 02:04:26 +00:00
|
|
|
image: {
|
|
|
|
url,
|
|
|
|
},
|
2021-06-02 00:31:39 +00:00
|
|
|
},
|
2021-08-30 02:04:26 +00:00
|
|
|
],
|
2021-06-02 00:31:39 +00:00
|
|
|
};
|
|
|
|
}
|
2022-11-30 01:15:41 +00:00
|
|
|
} else if (user) {
|
|
|
|
const lookup = await lookupUser(msg, user);
|
2021-06-02 00:31:39 +00:00
|
|
|
if (
|
2022-11-30 01:15:41 +00:00
|
|
|
lookup == "No results" ||
|
|
|
|
lookup == "Canceled" ||
|
|
|
|
lookup == "Request timed out"
|
2021-06-02 00:31:39 +00:00
|
|
|
) {
|
2022-11-30 01:15:41 +00:00
|
|
|
return lookup;
|
2021-06-02 00:31:39 +00:00
|
|
|
} else {
|
2022-11-30 01:15:41 +00:00
|
|
|
let member = lookup;
|
2021-08-30 18:01:33 +00:00
|
|
|
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
|
|
|
if (guild) {
|
2022-11-30 01:15:41 +00:00
|
|
|
if (guild.members.has(lookup.id)) {
|
|
|
|
member = guild.members.get(lookup.id);
|
2021-08-30 02:12:56 +00:00
|
|
|
} else {
|
2021-08-30 18:01:33 +00:00
|
|
|
const fetched = await guild.fetchMembers({
|
2022-11-30 01:15:41 +00:00
|
|
|
userIDs: [lookup.id],
|
2021-08-30 02:12:56 +00:00
|
|
|
});
|
|
|
|
member = fetched[0];
|
|
|
|
}
|
|
|
|
}
|
2022-04-03 16:37:26 +00:00
|
|
|
|
|
|
|
const baseEmbed = {
|
2022-10-09 18:34:36 +00:00
|
|
|
title: `Avatar for \`${member.tag}\``,
|
2022-04-03 16:37:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const normalAvatar = member.user.avatar;
|
|
|
|
const guildAvatar = member.avatar;
|
|
|
|
|
|
|
|
const normalUrl =
|
|
|
|
AVATAR_BASE +
|
|
|
|
member.id +
|
|
|
|
"/" +
|
|
|
|
normalAvatar +
|
|
|
|
"." +
|
2022-04-03 16:40:19 +00:00
|
|
|
(normalAvatar.startsWith("a_")
|
2022-04-03 16:37:26 +00:00
|
|
|
? "gif?size=1024&_=.gif"
|
2022-04-03 16:40:19 +00:00
|
|
|
: "png?size=1024");
|
2022-04-03 16:37:26 +00:00
|
|
|
const guildUrl =
|
2022-04-03 16:42:05 +00:00
|
|
|
guildAvatar &&
|
2022-04-03 16:37:26 +00:00
|
|
|
"https://cdn.discordapp.com/guilds/" +
|
2022-04-03 16:42:05 +00:00
|
|
|
guild.id +
|
|
|
|
"/users/" +
|
|
|
|
member.id +
|
|
|
|
"/avatars/" +
|
|
|
|
guildAvatar +
|
|
|
|
"." +
|
|
|
|
(guildAvatar.startsWith("a_")
|
|
|
|
? "gif?size=1024&_=.gif"
|
|
|
|
: "png?size=1024");
|
2022-04-03 16:37:26 +00:00
|
|
|
|
|
|
|
baseEmbed.description =
|
|
|
|
`[Normal avatar](${normalUrl})` +
|
|
|
|
(guild && guildAvatar ? `\n[Guild avatar](${guildUrl})` : "");
|
2022-04-03 16:53:40 +00:00
|
|
|
baseEmbed.url = normalUrl;
|
2022-04-03 16:37:26 +00:00
|
|
|
|
2022-04-03 16:45:25 +00:00
|
|
|
const guildEmbed = {...baseEmbed};
|
2022-04-03 16:37:26 +00:00
|
|
|
baseEmbed.image = {url: normalUrl};
|
|
|
|
guildEmbed.image = {url: guildUrl};
|
|
|
|
|
2021-06-02 00:31:39 +00:00
|
|
|
return {
|
2022-04-03 16:44:11 +00:00
|
|
|
embeds: [baseEmbed, guildAvatar && guildEmbed].filter((x) => x != null),
|
2021-06-02 00:31:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
} else {
|
2021-08-30 18:01:33 +00:00
|
|
|
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
2022-04-03 16:40:19 +00:00
|
|
|
|
|
|
|
const baseEmbed = {
|
2022-10-09 18:34:36 +00:00
|
|
|
title: `Avatar for \`${msg.author.tag}\``,
|
2022-04-03 16:40:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const normalAvatar = msg.author.avatar;
|
|
|
|
const guildAvatar = msg.member?.avatar;
|
|
|
|
|
|
|
|
const normalUrl =
|
|
|
|
AVATAR_BASE +
|
|
|
|
msg.author.id +
|
|
|
|
"/" +
|
|
|
|
normalAvatar +
|
|
|
|
"." +
|
|
|
|
(normalAvatar.startsWith("a_")
|
|
|
|
? "gif?size=1024&_=.gif"
|
|
|
|
: "png?size=1024");
|
|
|
|
const guildUrl =
|
2022-04-03 16:42:05 +00:00
|
|
|
guildAvatar &&
|
2022-04-03 16:40:19 +00:00
|
|
|
"https://cdn.discordapp.com/guilds/" +
|
2022-04-03 16:42:05 +00:00
|
|
|
guild.id +
|
|
|
|
"/users/" +
|
|
|
|
msg.author.id +
|
|
|
|
"/avatars/" +
|
|
|
|
guildAvatar +
|
|
|
|
"." +
|
|
|
|
(guildAvatar.startsWith("a_")
|
|
|
|
? "gif?size=1024&_=.gif"
|
|
|
|
: "png?size=1024");
|
2022-04-03 16:40:19 +00:00
|
|
|
|
|
|
|
baseEmbed.description =
|
|
|
|
`[Normal avatar](${normalUrl})` +
|
|
|
|
(guild && guildAvatar ? `\n[Guild avatar](${guildUrl})` : "");
|
2022-04-05 16:55:05 +00:00
|
|
|
baseEmbed.url = normalUrl;
|
2022-04-03 16:40:19 +00:00
|
|
|
|
2022-04-03 16:45:25 +00:00
|
|
|
const guildEmbed = {...baseEmbed};
|
2022-04-03 16:40:19 +00:00
|
|
|
baseEmbed.image = {url: normalUrl};
|
|
|
|
guildEmbed.image = {url: guildUrl};
|
|
|
|
|
2021-06-02 00:31:39 +00:00
|
|
|
return {
|
2022-04-03 16:44:11 +00:00
|
|
|
embeds: [baseEmbed, guildAvatar && guildEmbed].filter((x) => x != null),
|
2021-06-02 00:31:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
hf.registerCommand(avatar);
|
2021-06-02 00:58:39 +00:00
|
|
|
|
2021-07-28 17:56:27 +00:00
|
|
|
const banner = new Command("banner");
|
|
|
|
banner.category = CATEGORY;
|
|
|
|
banner.helpText = "Get banner of a user";
|
|
|
|
banner.usage = "<user>";
|
2022-11-30 01:15:41 +00:00
|
|
|
banner.callback = async function (msg, line, [user], {server, guild}) {
|
2021-07-28 17:56:27 +00:00
|
|
|
let id = msg.author.id;
|
|
|
|
|
2022-11-30 01:15:41 +00:00
|
|
|
if (server || guild) {
|
2021-08-30 18:01:33 +00:00
|
|
|
if (!msg.guildID) {
|
2021-08-26 17:18:50 +00:00
|
|
|
return "`--server/--guild` can only be used within guilds.";
|
|
|
|
} else {
|
2021-08-30 18:01:33 +00:00
|
|
|
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
2021-08-31 15:49:21 +00:00
|
|
|
|
|
|
|
if (!guild.banner) return "This guild does not have a banner.";
|
|
|
|
|
2021-08-30 18:01:33 +00:00
|
|
|
const url = `${BANNER_BASE}${guild.id}/${guild.banner}.${
|
|
|
|
guild.banner.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024"
|
2021-08-26 17:18:50 +00:00
|
|
|
}`;
|
|
|
|
return {
|
2021-08-30 02:04:26 +00:00
|
|
|
embeds: [
|
|
|
|
{
|
|
|
|
title: "Server Banner",
|
2021-08-26 17:18:50 +00:00
|
|
|
url,
|
2021-08-30 02:04:26 +00:00
|
|
|
image: {
|
|
|
|
url,
|
|
|
|
},
|
2021-08-26 17:18:50 +00:00
|
|
|
},
|
2021-08-30 02:04:26 +00:00
|
|
|
],
|
2021-08-26 17:18:50 +00:00
|
|
|
};
|
|
|
|
}
|
2022-11-30 01:15:41 +00:00
|
|
|
} else if (user) {
|
|
|
|
const lookup = await lookupUser(msg, user);
|
2021-07-28 17:56:27 +00:00
|
|
|
if (
|
|
|
|
lookup == "No results" ||
|
|
|
|
lookup == "Canceled" ||
|
|
|
|
lookup == "Request timed out"
|
|
|
|
) {
|
|
|
|
return lookup;
|
|
|
|
} else {
|
|
|
|
id = lookup.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-30 02:36:17 +00:00
|
|
|
const userObj = await hf.bot.rest.authRequest({
|
2022-10-09 18:23:48 +00:00
|
|
|
method: "GET",
|
|
|
|
path: "/users/" + id,
|
|
|
|
});
|
2021-07-28 17:56:27 +00:00
|
|
|
|
2022-11-30 02:36:17 +00:00
|
|
|
if (!userObj.banner) return "This user does not have a banner.";
|
2021-07-28 17:56:27 +00:00
|
|
|
|
2022-11-30 02:36:17 +00:00
|
|
|
const url = `${BANNER_BASE}${userObj.id}/${userObj.banner}.${
|
|
|
|
userObj.banner.startsWith("a_") ? "gif?size=1024&_=.gif" : "png?size=1024"
|
2021-07-28 17:56:27 +00:00
|
|
|
}`;
|
|
|
|
return {
|
2021-08-30 02:04:26 +00:00
|
|
|
embeds: [
|
|
|
|
{
|
2022-11-30 02:36:17 +00:00
|
|
|
title: `Banner for \`${userObj.username}#${userObj.discriminator}\``,
|
2021-07-28 17:56:27 +00:00
|
|
|
url,
|
2021-08-30 02:04:26 +00:00
|
|
|
image: {
|
|
|
|
url,
|
|
|
|
},
|
2021-07-28 17:56:27 +00:00
|
|
|
},
|
2021-08-30 02:04:26 +00:00
|
|
|
],
|
2021-07-28 17:56:27 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
hf.registerCommand(banner);
|
|
|
|
|
2021-06-02 00:58:39 +00:00
|
|
|
const lookupinvite = new Command("lookupinvite");
|
|
|
|
lookupinvite.category = CATEGORY;
|
|
|
|
lookupinvite.helpText = "Lookup an invite";
|
|
|
|
lookupinvite.usage = "<invite code>";
|
|
|
|
lookupinvite.addAlias("linvite");
|
|
|
|
lookupinvite.callback = async function (msg, line) {
|
|
|
|
if (!line) {
|
|
|
|
return "No arguments passed.";
|
|
|
|
}
|
|
|
|
|
|
|
|
line = line.replace(/(https?:\/\/)?discord\.gg\//, "");
|
|
|
|
|
2022-10-09 18:23:48 +00:00
|
|
|
const invite = await hf.bot.rest.request({
|
|
|
|
method: "GET",
|
|
|
|
path: "/invites/" + line + "?with_counts=1",
|
|
|
|
});
|
2021-06-02 00:58:39 +00:00
|
|
|
if (!invite) return ":warning: No data returned.";
|
|
|
|
|
|
|
|
if (invite.message) {
|
|
|
|
if (invite.message == "Unknown Invite") {
|
|
|
|
return "Invite provided is not valid.";
|
|
|
|
} else {
|
|
|
|
return `:warning: Got error \`${invite.code}: "${invite.message}"\``;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const embed = {
|
|
|
|
title: `Invite Info: \`${invite.code}\``,
|
|
|
|
description: invite.description,
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: "Guild",
|
|
|
|
value: `**${invite.guild.name}** (${invite.guild.id})`,
|
|
|
|
inline: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Channel",
|
|
|
|
value: `**${invite.channel.name}** (${invite.channel.id})`,
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Features",
|
|
|
|
value:
|
|
|
|
invite.guild.features.length > 0
|
|
|
|
? invite.guild.features
|
|
|
|
.map((feature) =>
|
|
|
|
feature
|
|
|
|
.split("_")
|
|
|
|
.map((x) => x[0] + x.substring(1).toLowerCase())
|
|
|
|
.join(" ")
|
|
|
|
)
|
|
|
|
.join(", ")
|
|
|
|
: "None",
|
|
|
|
inline: false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
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"
|
|
|
|
}`,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
if (invite.inviter) {
|
|
|
|
embed.fields.push({
|
|
|
|
name: "Inviter",
|
|
|
|
value: `**${invite.inviter.username}#${invite.inviter.discriminator}** (${invite.inviter.id})`,
|
|
|
|
inline: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invite.guild.icon || invite.guild.splash || invite.guild.banner) {
|
|
|
|
embed.fields.push({
|
|
|
|
name: "\u200b",
|
|
|
|
value: `${
|
|
|
|
invite.guild.icon
|
|
|
|
? `[Icon](${ICON_BASE}${invite.guild.id}/${invite.guild.icon}.${
|
|
|
|
invite.guild.icon.startsWith("a_")
|
|
|
|
? "gif?size=1024"
|
|
|
|
: "png?size=1024"
|
|
|
|
})`
|
|
|
|
: ""
|
|
|
|
}${
|
|
|
|
invite.guild.splash
|
|
|
|
? `${invite.guild.icon ? " | " : ""}[Splash](${SPLASH_BASE}${
|
|
|
|
invite.guild.id
|
|
|
|
}/${invite.guild.splash}.png?size=2048)`
|
|
|
|
: ""
|
|
|
|
}${
|
|
|
|
invite.guild.banner
|
|
|
|
? `${
|
|
|
|
invite.guild.icon || invite.guild.splash ? " | " : ""
|
|
|
|
}[Banner](${BANNER_BASE}${invite.guild.id}/${
|
|
|
|
invite.guild.banner
|
|
|
|
}.png?size=2048)`
|
|
|
|
: ""
|
|
|
|
}`,
|
|
|
|
inline: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (invite.guild.splash) {
|
|
|
|
embed.image = {
|
|
|
|
url: `${SPLASH_BASE}${invite.guild.id}/${invite.guild.splash}.png?size=256`,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {embed};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
hf.registerCommand(lookupinvite);
|
2021-06-11 03:54:17 +00:00
|
|
|
|
|
|
|
const snowflake = new Command("snowflake");
|
|
|
|
snowflake.category = CATEGORY;
|
|
|
|
snowflake.helpText = "Converts a snowflake ID into readable time.";
|
|
|
|
snowflake.usage = "<--twitter> [snowflake]";
|
2022-11-30 01:15:41 +00:00
|
|
|
snowflake.callback = function (msg, line, [snowflake], {twitter}) {
|
|
|
|
const num = parseInt(snowflake);
|
2021-06-11 03:54:17 +00:00
|
|
|
if (!isNaN(num)) {
|
|
|
|
let binary = num.toString(2);
|
|
|
|
binary = "0".repeat(64 - binary.length) + binary;
|
|
|
|
const timestamp =
|
|
|
|
parseInt(binary.substr(0, 42), 2) +
|
|
|
|
(twitter ? 1288834974657 : 1420070400000);
|
|
|
|
|
2022-11-30 01:15:41 +00:00
|
|
|
return `The timestamp for \`${snowflake}\` is <t:${Math.floor(
|
|
|
|
timestamp / 1000
|
|
|
|
)}:F>`;
|
2021-06-11 03:54:17 +00:00
|
|
|
} else {
|
|
|
|
return "Argument provided is not a number.";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
hf.registerCommand(snowflake);
|
2021-06-22 04:22:32 +00:00
|
|
|
|
|
|
|
const USER_FLAGS = [
|
|
|
|
"STAFF",
|
|
|
|
"PARTNER",
|
|
|
|
"HYPESQUAD",
|
|
|
|
"BUG_HUNTER_LEVEL_1",
|
|
|
|
"MFA_SMS",
|
|
|
|
"PREMIUM_PROMO_DISMISSED",
|
|
|
|
"HYPESQUAD_ONLINE_HOUSE_1",
|
|
|
|
"HYPESQUAD_ONLINE_HOUSE_2",
|
|
|
|
"HYPESQUAD_ONLINE_HOUSE_3",
|
|
|
|
"PREMIUM_EARLY_SUPPORTER",
|
|
|
|
"TEAM_PSEUDO_USER",
|
2022-10-23 01:22:03 +00:00
|
|
|
"<Internal Application (Partner, etc) Flag>", // leaked
|
2021-06-22 04:22:32 +00:00
|
|
|
"SYSTEM",
|
|
|
|
"HAS_UNREAD_URGENT_MESSAGES",
|
|
|
|
"BUG_HUNTER_LEVEL_2",
|
|
|
|
"UNDERAGE_DELETED",
|
|
|
|
"VERIFIED_BOT",
|
|
|
|
"VERIFIED_DEVELOPER",
|
|
|
|
"CERTIFIED_MODERATOR",
|
2021-10-16 03:12:59 +00:00
|
|
|
"BOT_HTTP_INTERACTIONS",
|
2021-10-16 03:09:55 +00:00
|
|
|
"SPAMMER",
|
2022-07-21 18:47:38 +00:00
|
|
|
"DISABLE_PREMIUM",
|
2022-11-21 17:54:30 +00:00
|
|
|
"ACTIVE_DEVELOPER",
|
2021-08-04 23:15:21 +00:00
|
|
|
undefined,
|
|
|
|
undefined,
|
|
|
|
undefined,
|
|
|
|
undefined,
|
|
|
|
undefined,
|
|
|
|
undefined,
|
|
|
|
undefined,
|
|
|
|
undefined,
|
|
|
|
undefined,
|
|
|
|
undefined,
|
2022-10-23 01:22:03 +00:00
|
|
|
"HIGH_GLOBAL_RATE_LIMIT", // start admin panel leak aug 2022
|
|
|
|
"DELETED",
|
|
|
|
"DISABLED_SUSPICIOUS_ACTIVITY",
|
|
|
|
"SELF_DELETED",
|
|
|
|
"PREMIUM_DISCRIMINATOR",
|
|
|
|
"USED_DESKTOP_CLIENT",
|
|
|
|
"USED_WEB_CLIENT",
|
|
|
|
"USED_MOBILE_CLIENT",
|
|
|
|
"DISABLED",
|
2021-08-04 23:15:21 +00:00
|
|
|
undefined,
|
2022-10-23 01:22:03 +00:00
|
|
|
"VERIFIED_EMAIL", // end admin panel leak aug 2022
|
2022-07-21 18:47:38 +00:00
|
|
|
"QUARANTINED",
|
2021-06-22 04:22:32 +00:00
|
|
|
];
|
|
|
|
|
2021-06-22 04:35:04 +00:00
|
|
|
function flagFromInt(int) {
|
|
|
|
const bits = int.toString(2);
|
|
|
|
const splitBits = bits.split("").reverse();
|
2021-06-22 04:22:32 +00:00
|
|
|
|
2021-06-22 04:35:04 +00:00
|
|
|
const reassignedBits = {};
|
2021-06-22 04:22:32 +00:00
|
|
|
|
2021-06-22 04:35:04 +00:00
|
|
|
for (const shift in splitBits) {
|
|
|
|
reassignedBits[shift] = splitBits[shift];
|
|
|
|
}
|
2021-06-22 04:22:32 +00:00
|
|
|
|
2021-06-22 04:35:04 +00:00
|
|
|
const flags = Object.keys(reassignedBits).filter(
|
|
|
|
(bit) => reassignedBits[bit] == 1
|
|
|
|
);
|
2021-06-22 04:22:32 +00:00
|
|
|
|
2021-06-22 04:35:04 +00:00
|
|
|
let out = "";
|
|
|
|
|
|
|
|
for (const flag of flags) {
|
|
|
|
out +=
|
|
|
|
(USER_FLAGS[flag] || "<Undocumented Flag>") +
|
|
|
|
` (1 << ${flag}, ${1n << BigInt(flag)})\n`;
|
|
|
|
}
|
2021-06-22 04:22:32 +00:00
|
|
|
|
2021-06-22 04:35:04 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
const flagdump = new Command("flagdump");
|
|
|
|
flagdump.category = CATEGORY;
|
|
|
|
flagdump.helpText = "Dumps Discord user flags.";
|
|
|
|
flagdump.usage = "[flags or user mention]";
|
2022-11-30 01:15:41 +00:00
|
|
|
flagdump.callback = async function (msg, line, [numOrMention], {id}) {
|
|
|
|
const num = Number(numOrMention);
|
|
|
|
if (/<@!?(\d+)>/.test(numOrMention) || !isNaN(id)) {
|
|
|
|
const targetId = id || numOrMention.match(/<@!?(\d+)>/)?.[1];
|
|
|
|
if (!targetId) return "Got null ID.";
|
2021-08-30 18:01:33 +00:00
|
|
|
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
2022-11-30 01:15:41 +00:00
|
|
|
let user = guild && (await guild.fetchMembers({userIDs: [targetId]}));
|
2021-08-30 18:01:33 +00:00
|
|
|
if (!user || !user[0]) {
|
2021-06-22 04:35:04 +00:00
|
|
|
user = hf.bot.users.get(id);
|
|
|
|
} else {
|
|
|
|
user = user[0].user;
|
2021-06-22 04:22:32 +00:00
|
|
|
}
|
|
|
|
|
2021-06-22 04:35:04 +00:00
|
|
|
if (!user) {
|
|
|
|
return "User not cached.";
|
|
|
|
} else {
|
2022-10-09 18:34:36 +00:00
|
|
|
return `\`${user.tag}\`'s public flags:\n\`\`\`${flagFromInt(
|
|
|
|
user.publicFlags
|
|
|
|
)}\`\`\``;
|
2021-06-22 04:35:04 +00:00
|
|
|
}
|
|
|
|
} else if (!isNaN(num)) {
|
|
|
|
return `\`\`\`\n${flagFromInt(num)}\`\`\``;
|
2021-06-22 04:22:32 +00:00
|
|
|
} else {
|
2022-10-09 18:34:36 +00:00
|
|
|
return `\`${msg.author.tag}\`'s public flags:\n\`\`\`${flagFromInt(
|
|
|
|
msg.author.publicFlags
|
|
|
|
)}\`\`\``;
|
2021-06-22 04:22:32 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
hf.registerCommand(flagdump);
|
2021-08-12 03:31:56 +00:00
|
|
|
|
|
|
|
const emojiNames = [];
|
|
|
|
fetch("https://unpkg.com/emoji.json/emoji.json")
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((body) =>
|
|
|
|
body.map(
|
|
|
|
(emoji) => (emojiNames[emoji.char] = emoji.name.replace(/ /g, "_"))
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
const jumbo = new Command("jumbo");
|
|
|
|
jumbo.category = CATEGORY;
|
|
|
|
jumbo.helpText = "Gets the raw image of an emoji.";
|
|
|
|
jumbo.usage = "<emoji>";
|
|
|
|
jumbo.addAlias("e");
|
|
|
|
jumbo.addAlias("emote");
|
|
|
|
jumbo.addAlias("emoji");
|
|
|
|
jumbo.callback = async function (msg, line) {
|
|
|
|
if (CUSTOM_EMOTE_REGEX.test(line)) {
|
2021-08-12 03:33:58 +00:00
|
|
|
const [_, animatedFlag, name, id] = line.match(CUSTOM_EMOTE_REGEX);
|
2021-08-12 03:31:56 +00:00
|
|
|
const animated = animatedFlag === "a";
|
|
|
|
|
|
|
|
return {
|
2021-08-30 02:04:26 +00:00
|
|
|
embeds: [
|
|
|
|
{
|
|
|
|
title: `:${name}: - \`${id}\``,
|
2021-08-12 03:31:56 +00:00
|
|
|
url: `${EMOTE_BASE}${id}.${animated ? "gif" : "png"}?v=1`,
|
2021-08-30 02:04:26 +00:00
|
|
|
image: {
|
|
|
|
url: `${EMOTE_BASE}${id}.${animated ? "gif" : "png"}?v=1`,
|
|
|
|
},
|
2021-08-12 03:31:56 +00:00
|
|
|
},
|
2021-08-30 02:04:26 +00:00
|
|
|
],
|
2021-08-12 03:31:56 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
let setName = "twemoji";
|
|
|
|
for (const set in EMOJI_SETS) {
|
|
|
|
if (line.startsWith(`--${set} `)) {
|
|
|
|
setName = set;
|
|
|
|
line = line.replace(`--${set} `, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const set = EMOJI_SETS[setName];
|
|
|
|
|
|
|
|
const emoji = Array.from(line)
|
|
|
|
.map((char) => char.codePointAt().toString(16))
|
|
|
|
.join(set.sep);
|
|
|
|
const url = set.prefix + emoji + set.suffix;
|
|
|
|
|
|
|
|
const name = emojiNames[line]
|
|
|
|
? `\\:${emojiNames[line]}\\:`
|
2022-10-12 15:08:35 +00:00
|
|
|
: await getNamesFromString(line).then((name) =>
|
|
|
|
name.map((x) => x[1]).join(", ")
|
|
|
|
);
|
2021-08-12 03:31:56 +00:00
|
|
|
|
|
|
|
const statusCode = await fetch(url, {method: "HEAD"}).then(
|
|
|
|
(res) => res.status
|
|
|
|
);
|
|
|
|
|
|
|
|
if (statusCode !== 200) {
|
|
|
|
return "Emoji not found. The emoji set chosen might not have this emote as an image.";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set.suffix == ".svg") {
|
2022-10-10 19:13:02 +00:00
|
|
|
const svg = await fetch(url)
|
|
|
|
.then((res) => res.arrayBuffer())
|
|
|
|
.then((b) => Buffer.from(b));
|
2021-08-12 03:31:56 +00:00
|
|
|
const converted = await sharp(svg, {density: 2400})
|
|
|
|
.resize(1024)
|
|
|
|
.toBuffer();
|
|
|
|
|
|
|
|
return {
|
2021-08-30 02:04:26 +00:00
|
|
|
embeds: [
|
|
|
|
{
|
|
|
|
title: `${name} (${emoji.toUpperCase().replace(/[-_]/g, ", ")})`,
|
|
|
|
url,
|
|
|
|
image: {
|
|
|
|
url: "attachment://emoji.png",
|
|
|
|
},
|
2021-08-12 03:31:56 +00:00
|
|
|
},
|
2021-08-30 02:04:26 +00:00
|
|
|
],
|
2021-08-12 03:31:56 +00:00
|
|
|
file: {
|
|
|
|
file: converted,
|
|
|
|
name: "emoji.png",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return {
|
2021-08-30 02:04:26 +00:00
|
|
|
embeds: [
|
|
|
|
{
|
|
|
|
title: `${name} (${emoji.toUpperCase().replace(/[-_]/g, ", ")})`,
|
2021-08-12 03:31:56 +00:00
|
|
|
url,
|
2021-08-30 02:04:26 +00:00
|
|
|
image: {
|
|
|
|
url,
|
|
|
|
},
|
2021-08-12 03:31:56 +00:00
|
|
|
},
|
2021-08-30 02:04:26 +00:00
|
|
|
],
|
2021-08-12 03:31:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
hf.registerCommand(jumbo);
|
2022-03-29 17:38:02 +00:00
|
|
|
|
|
|
|
const charinfo = new Command("charinfo");
|
|
|
|
charinfo.category = CATEGORY;
|
2022-08-16 22:54:27 +00:00
|
|
|
charinfo.helpText = "Get information about a set of characters.";
|
2022-03-29 17:38:02 +00:00
|
|
|
charinfo.usage = "[characters]";
|
|
|
|
charinfo.addAlias("char");
|
|
|
|
charinfo.callback = async function (msg, line) {
|
2022-03-29 17:46:40 +00:00
|
|
|
const names = await getNamesFromString(line);
|
2022-03-29 17:38:02 +00:00
|
|
|
const chars = [...line];
|
|
|
|
const lines = names
|
|
|
|
.map(
|
|
|
|
([code, name], index) =>
|
|
|
|
`\`\\u${code}\`: ${name} - ${chars[index]} - <http://www.fileformat.info/info/unicode/char/${code}>`
|
|
|
|
)
|
|
|
|
.join("\n");
|
|
|
|
|
|
|
|
if (lines.length > 2000) {
|
2022-04-02 02:07:15 +00:00
|
|
|
return "Output too long: " + (await hastebin(lines));
|
2022-03-29 17:38:02 +00:00
|
|
|
} else {
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
hf.registerCommand(charinfo);
|
2022-10-10 04:38:15 +00:00
|
|
|
|
|
|
|
const PRESENCE_ICONS = {
|
|
|
|
desktop: {
|
|
|
|
online: "<:desktop_online:1028887024670871552>",
|
|
|
|
idle: "<:desktop_idle:1028887022938624033>",
|
|
|
|
dnd: "<:desktop_dnd:1028887021848121364>",
|
|
|
|
},
|
|
|
|
mobile: {
|
|
|
|
online: "<:mobile_online:1028887017637036043>",
|
|
|
|
idle: "<:mobile_idle:1028887019226669116>",
|
|
|
|
dnd: "<:mobile_dnd:1028887020560449637>",
|
|
|
|
},
|
|
|
|
web: {
|
|
|
|
online: "<:web_online:1028887016353574962>",
|
|
|
|
idle: "<:web_idle:1028887014579392592>",
|
|
|
|
dnd: "<:web_dnd:1028887012855525486>",
|
|
|
|
},
|
|
|
|
embedded: {
|
|
|
|
online: "<:embedded_online:1028887010636726313>",
|
|
|
|
idle: "<:embedded_idle:1028887009147760681>",
|
|
|
|
dnd: "<:embedded_dnd:1028887008149516299>",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-10-10 19:13:02 +00:00
|
|
|
const PRESENCE_TYPES = [
|
|
|
|
"Playing",
|
|
|
|
"Streaming",
|
|
|
|
"Listening to",
|
|
|
|
"Watching",
|
|
|
|
"",
|
|
|
|
"Competing in",
|
|
|
|
];
|
|
|
|
|
|
|
|
const NOWPLAYING_BAR_LENGTH = 30;
|
|
|
|
|
2022-10-10 04:38:15 +00:00
|
|
|
const presence = new Command("presence");
|
|
|
|
presence.category = CATEGORY;
|
|
|
|
presence.helpText = "Get presences of a user.";
|
|
|
|
presence.usage = "<user>";
|
|
|
|
presence.callback = async function (msg, line) {
|
|
|
|
if (!msg.guildID) return "Can only be used in guilds.";
|
|
|
|
|
|
|
|
let target;
|
|
|
|
if (line) {
|
|
|
|
const user = await lookupUser(msg, line);
|
|
|
|
if (
|
|
|
|
user == "No results" ||
|
|
|
|
user == "Canceled" ||
|
|
|
|
user == "Request timed out"
|
|
|
|
) {
|
|
|
|
return user;
|
|
|
|
} else {
|
|
|
|
let member = user;
|
|
|
|
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
|
|
|
if (guild) {
|
|
|
|
if (guild.members.has(user.id)) {
|
|
|
|
member = guild.members.get(user.id);
|
|
|
|
} else {
|
|
|
|
const fetched = await guild.fetchMembers({
|
|
|
|
userIDs: [user.id],
|
|
|
|
});
|
|
|
|
member = fetched[0];
|
|
|
|
}
|
2022-10-10 19:13:02 +00:00
|
|
|
target = member;
|
2022-10-10 04:38:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target = msg.member;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target) {
|
|
|
|
if (!target.presence) return `**${target.tag}** is offline.`;
|
|
|
|
|
|
|
|
let icons = "";
|
|
|
|
for (const platform in target.presence.client_status) {
|
|
|
|
const status = target.presence.client_status[platform];
|
|
|
|
|
|
|
|
icons += PRESENCE_ICONS[platform][status] + " ";
|
|
|
|
}
|
|
|
|
|
|
|
|
const embeds = [];
|
2022-10-10 19:13:02 +00:00
|
|
|
const files = [];
|
|
|
|
|
|
|
|
for (const index in target.presence.activities) {
|
|
|
|
const activity = target.presence.activities[index];
|
|
|
|
if (activity.type == 4) {
|
|
|
|
let emote = "";
|
2022-10-10 19:42:02 +00:00
|
|
|
if (activity.emoji) {
|
|
|
|
if (activity.emoji.id) {
|
|
|
|
emote = `<${activity.emoji.animated ? "a" : ""}:${
|
|
|
|
activity.emoji.name
|
|
|
|
}:${activity.emoji.id}>`;
|
|
|
|
} else {
|
|
|
|
emote = activity.emoji.name;
|
|
|
|
}
|
2022-10-10 19:13:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
embeds.push({
|
2022-10-11 01:46:09 +00:00
|
|
|
title: `${emote} ${activity.state ?? ""}`,
|
2022-10-10 19:13:02 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
const embed = {
|
|
|
|
title: `${PRESENCE_TYPES[activity.type]} **${activity.name}**`,
|
|
|
|
};
|
|
|
|
const descLines = [];
|
|
|
|
if (activity.type == 2) {
|
|
|
|
if (activity.details) descLines.push(`**${activity.details}**`);
|
|
|
|
if (activity.state) descLines.push(activity.state);
|
|
|
|
if (activity.assets?.large_text)
|
|
|
|
descLines.push(activity.assets.large_text);
|
|
|
|
} else {
|
|
|
|
if (activity.details) descLines.push(activity.details);
|
|
|
|
if (activity.state) descLines.push(activity.state);
|
|
|
|
}
|
|
|
|
|
2022-10-10 19:16:28 +00:00
|
|
|
if (activity.timestamps) {
|
|
|
|
if (activity.timestamps.start && !activity.timestamps.end) {
|
|
|
|
descLines.push(
|
|
|
|
formatTime(Date.now() - activity.timestamps.start) + " elapsed"
|
|
|
|
);
|
|
|
|
} else if (!activity.timestamps.start && activity.timestamps.end) {
|
|
|
|
descLines.push(
|
|
|
|
formatTime(activity.timestamps.end - Date.now()) + " remaining"
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
const position = Date.now() - activity.timestamps.start;
|
|
|
|
const length = activity.timestamps.end - activity.timestamps.start;
|
|
|
|
|
|
|
|
const timeEnd = formatTime(length);
|
|
|
|
const timePos = formatTime(position);
|
|
|
|
|
2022-10-10 19:26:03 +00:00
|
|
|
const progress =
|
|
|
|
activity.timestamps.start == activity.timestamps.end
|
|
|
|
? 1
|
|
|
|
: position / length;
|
2022-10-10 19:16:28 +00:00
|
|
|
const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH);
|
|
|
|
|
|
|
|
const bar = `\`[${"=".repeat(barLength)}${" ".repeat(
|
|
|
|
NOWPLAYING_BAR_LENGTH - barLength
|
|
|
|
)}]\``;
|
|
|
|
const time = `\`${timePos}${" ".repeat(
|
|
|
|
NOWPLAYING_BAR_LENGTH + 2 - timePos.length - timeEnd.length
|
|
|
|
)}${timeEnd}\``;
|
|
|
|
|
|
|
|
descLines.push(bar);
|
|
|
|
descLines.push(time);
|
|
|
|
}
|
2022-10-10 19:13:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 20:30:14 +00:00
|
|
|
if (activity.buttons && activity.metadata?.button_urls) {
|
|
|
|
const buttons = [];
|
|
|
|
for (let i = 0; i < activity.buttons.length; i++) {
|
|
|
|
buttons.push(
|
|
|
|
`[${activity.buttons[i]}](${activity.metadata.button_urls[i]})`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
descLines.push(buttons.join(" | "));
|
|
|
|
}
|
|
|
|
|
2022-10-10 19:13:02 +00:00
|
|
|
embed.description = descLines.join("\n");
|
|
|
|
|
2022-10-10 19:21:17 +00:00
|
|
|
if (activity.assets) {
|
|
|
|
if (activity.assets.large_image != null) {
|
|
|
|
let largeUrl;
|
|
|
|
if (activity.assets.large_image.startsWith("mp:")) {
|
2022-10-10 19:22:19 +00:00
|
|
|
largeUrl = activity.assets.large_image.replace(
|
2022-10-10 19:21:17 +00:00
|
|
|
"mp:",
|
|
|
|
"https://media.discordapp.net/"
|
|
|
|
);
|
2022-10-10 19:37:44 +00:00
|
|
|
} else if (activity.assets.large_image.startsWith("spotify:")) {
|
|
|
|
largeUrl = activity.assets.large_image.replace(
|
|
|
|
"spotify:",
|
|
|
|
"https://i.scdn.co/image/"
|
|
|
|
);
|
2022-10-10 19:21:17 +00:00
|
|
|
} else {
|
|
|
|
largeUrl = `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.large_image}.png`;
|
|
|
|
}
|
|
|
|
|
|
|
|
let smallUrl;
|
|
|
|
if (activity.assets.small_image != null) {
|
|
|
|
if (activity.assets.small_image.startsWith("mp:")) {
|
2022-10-10 19:22:19 +00:00
|
|
|
smallUrl = activity.assets.small_image.replace(
|
2022-10-10 19:21:17 +00:00
|
|
|
"mp:",
|
|
|
|
"https://media.discordapp.net/"
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
smallUrl = `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.small_image}.png`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const largeImage = await fetch(largeUrl)
|
|
|
|
.then((res) => res.arrayBuffer())
|
|
|
|
.then((b) => Buffer.from(b));
|
|
|
|
const presenceImage = sharp(largeImage).resize(60, 60);
|
|
|
|
if (smallUrl) {
|
|
|
|
const smallImage = await fetch(smallUrl)
|
|
|
|
.then((res) => res.arrayBuffer())
|
|
|
|
.then((b) => Buffer.from(b));
|
|
|
|
const smallImageBuffer = await sharp(smallImage)
|
|
|
|
.resize(20, 20)
|
|
|
|
.toBuffer();
|
|
|
|
|
|
|
|
presenceImage.composite([
|
|
|
|
{
|
|
|
|
input: smallImageBuffer,
|
|
|
|
gravity: "southeast",
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}
|
2022-10-10 19:13:02 +00:00
|
|
|
|
2022-10-10 19:21:17 +00:00
|
|
|
files.push({
|
2022-10-10 19:27:43 +00:00
|
|
|
contents: await presenceImage.toBuffer(),
|
2022-10-10 19:21:17 +00:00
|
|
|
name: `${index}.png`,
|
|
|
|
});
|
|
|
|
embed.thumbnail = {
|
|
|
|
url: `attachment://${index}.png`,
|
|
|
|
};
|
|
|
|
} else if (
|
|
|
|
!activity.assets.large_image &&
|
|
|
|
activity.assets.small_image != null
|
|
|
|
) {
|
|
|
|
let smallUrl;
|
2022-10-10 19:13:02 +00:00
|
|
|
if (activity.assets.small_image.startsWith("mp:")) {
|
2022-10-10 19:22:19 +00:00
|
|
|
smallUrl = activity.assets.small_image.replace(
|
2022-10-10 19:13:02 +00:00
|
|
|
"mp:",
|
|
|
|
"https://media.discordapp.net/"
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
smallUrl = `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.small_image}.png`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const smallImage = await fetch(smallUrl)
|
|
|
|
.then((res) => res.arrayBuffer())
|
|
|
|
.then((b) => Buffer.from(b));
|
2022-10-10 19:21:17 +00:00
|
|
|
const presenceImage = await sharp(smallImage)
|
|
|
|
.resize(60, 60)
|
2022-10-10 19:14:22 +00:00
|
|
|
.toBuffer();
|
2022-10-10 19:13:02 +00:00
|
|
|
|
2022-10-10 19:21:17 +00:00
|
|
|
files.push({
|
2022-10-10 19:27:43 +00:00
|
|
|
contents: presenceImage,
|
2022-10-10 19:21:17 +00:00
|
|
|
name: `${index}.png`,
|
|
|
|
});
|
|
|
|
embed.thumbnail = {
|
|
|
|
url: `attachment://${index}.png`,
|
|
|
|
};
|
2022-10-10 19:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-10 19:21:17 +00:00
|
|
|
embeds.push(embed);
|
2022-10-10 19:13:02 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-10 04:38:15 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
content: `Presence for **${target.tag}**: ${icons}`,
|
2022-10-10 19:13:02 +00:00
|
|
|
embeds,
|
|
|
|
files,
|
2022-10-10 04:38:15 +00:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return ":warning: Could not get user???";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
hf.registerCommand(presence);
|