Compare commits

..

No commits in common. "68a313e0ab10d136d692d78b98ff6f45104f2899" and "83c49eb6ae718a4c8b968efa4aa6df6bba28a8d7" have entirely different histories.

43 changed files with 203 additions and 229 deletions

View file

@ -24,6 +24,7 @@
"dumpy": "github:Cynosphere/dumpy.js",
"google-images": "^2.1.0",
"jimp": "^0.22.7",
"module-alias": "^2.2.3",
"murmurhash": "^2.0.1",
"node-ffprobe": "^3.0.0",
"sharp": "^0.32.0",
@ -35,10 +36,10 @@
"husky": "^8.0.3",
"prettier": "^2.8.8"
},
"imports": {
"#root/*": "./*",
"#lib/*.js": "./src/lib/*.js",
"#util/*.js": "./src/util/*.js",
"#modules/*.js": "./src/modules/*.js"
"_moduleAliases": {
"@": ".",
"@lib": "src/lib",
"@util": "src/util",
"@modules": "src/modules"
}
}

View file

@ -26,6 +26,9 @@ importers:
jimp:
specifier: ^0.22.7
version: 0.22.7(encoding@0.1.13)
module-alias:
specifier: ^2.2.3
version: 2.2.3
murmurhash:
specifier: ^2.0.1
version: 2.0.1
@ -1097,6 +1100,9 @@ packages:
engines: {node: '>=10'}
hasBin: true
module-alias@2.2.3:
resolution: {integrity: sha512-23g5BFj4zdQL/b6tor7Ji+QY4pEfNH784BMslY9Qb0UnJWRAt+lQGLYmRaM0KDBwIG23ffEBELhZDP2rhi9f/Q==}
ms@2.1.2:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
@ -2824,6 +2830,8 @@ snapshots:
mkdirp@2.1.6: {}
module-alias@2.2.3: {}
ms@2.1.2: {}
ms@2.1.3:

View file

@ -1,19 +1,20 @@
require("module-alias/register");
const {Client, Collection, Channel, Permission} = require("@projectdysnomia/dysnomia");
const fs = require("node:fs");
const {resolve} = require("node:path");
const sqlite3 = require("sqlite3");
const {instead, before} = require("spitroast");
const config = require("#root/config.json");
const apikeys = require("#root/apikeys.json");
const config = require("@/config.json");
const apikeys = require("@/apikeys.json");
const logger = require("#lib/logger.js");
const events = require("#lib/events.js");
const timer = require("#lib/timer.js");
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const logger = require("@lib/logger.js");
const events = require("@lib/events.js");
const timer = require("@lib/timer.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {APIEndpoints, Intents, ApplicationCommandTypes, GatewayOPCodes} = require("#util/dconstants.js");
const {APIEndpoints, Intents, ApplicationCommandTypes, GatewayOPCodes} = require("@util/dconstants.js");
const bot = new Client(config.token, {
defaultImageFormat: "png",
@ -55,18 +56,17 @@ global.hf = {
database,
};
const {formatUsername} = require("#util/misc.js");
const CommandDispatcher = require("#lib/commandDispatcher.js");
const {InteractionDispatcher} = require("#lib/interactionDispatcher.js");
const {hasFlag} = require("#lib/guildSettings.js");
const {formatUsername} = require("@util/misc.js");
const CommandDispatcher = require("@lib/commandDispatcher.js");
const {InteractionDispatcher} = require("@lib/interactionDispatcher.js");
const {hasFlag} = require("@lib/guildSettings.js");
for (const file of fs.readdirSync(resolve(__dirname, "modules"), {withFileTypes: true})) {
if (file.isDirectory()) continue;
for (const file of fs.readdirSync(resolve(__dirname, "modules"))) {
try {
require(`#modules/${file.name}`);
logger.info("hf:modules", `Loaded module: "${file.name}"`);
require(`@modules/${file}`);
logger.info("hf:modules", `Loaded module: "${file}"`);
} catch (err) {
logger.error("hf:modules", `Failed to load "${file.name}": ${err}`);
logger.error("hf:modules", `Failed to load "${file}": ${err}`);
}
}

View file

@ -1,8 +1,8 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const CATEGORY = "bot";
const logger = require("#lib/logger.js");
const guildSettings = require("#lib/guildSettings.js");
const logger = require("@lib/logger.js");
const guildSettings = require("@lib/guildSettings.js");
const child_process = require("node:child_process");
const {inspect} = require("node:util");
@ -46,7 +46,7 @@ reload.category = CATEGORY;
reload.helpText = "Reloads a module.";
reload.callback = function (msg, line) {
try {
require.resolve(`#modules/${line}.js`);
require.resolve(`@modules/${line}.js`);
} catch (err) {
if (err.code == "MODULE_NOT_FOUND") {
return "Module not found.";
@ -58,8 +58,8 @@ reload.callback = function (msg, line) {
try {
logger.info("hf:modules", `Reloading module: "${line}"`);
delete require.cache[require.resolve(`#modules/${line}.js`)];
require(`#modules/${line}.js`);
delete require.cache[require.resolve(`@modules/${line}.js`)];
require(`@modules/${line}.js`);
return {reaction: "\uD83D\uDC4C"};
} catch (err) {
logger.info("hf:modules", `Failed to reload "${line}": ${err}`);

View file

@ -1,14 +1,14 @@
const {ApplicationCommandOptionTypes, MessageFlags} = require("#util/dconstants.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const {ApplicationCommandOptionTypes, MessageFlags} = require("@util/dconstants.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const events = require("#lib/events.js");
const {hasFlag} = require("#lib/guildSettings.js");
const events = require("@lib/events.js");
const {hasFlag} = require("@lib/guildSettings.js");
const REGEX_GITHUB =
/(?:\s|^)(\|\|\s*)?https?:\/\/(www\.)?github\.com\/[a-z0-9-]+\/[a-z0-9-._]+\/blob\/([a-z0-9-_.?&=#root/%]*)(\s*\|\|)?/gi;
/(?:\s|^)(\|\|\s*)?https?:\/\/(www\.)?github\.com\/[a-z0-9-]+\/[a-z0-9-._]+\/blob\/([a-z0-9-_.?&=#/%]*)(\s*\|\|)?/gi;
const REGEX_GITLAB =
/(?:\s|^)(\|\|\s*)?https?:\/\/.+?\/[a-z0-9-]+\/[a-z0-9-._]+\/-\/blob\/([a-z0-9-_.?&=#root/%]*)(\s*\|\|)?/gi;
/(?:\s|^)(\|\|\s*)?https?:\/\/.+?\/[a-z0-9-]+\/[a-z0-9-._]+\/-\/blob\/([a-z0-9-_.?&=#/%]*)(\s*\|\|)?/gi;
const REGEX_GITEA =
/(?:\s|^)(\|\|\s*)?https?:\/\/.+?\/[a-z0-9-]+\/[a-z0-9-._]+\/src\/(branch|commit)\/([a-z0-9-_.?&=#root/%]*)(\s*\|\|)?/gi;
/(?:\s|^)(\|\|\s*)?https?:\/\/.+?\/[a-z0-9-]+\/[a-z0-9-._]+\/src\/(branch|commit)\/([a-z0-9-_.?&=#/%]*)(\s*\|\|)?/gi;
const REGEX_SPOILER = /(?:\s|^)\|\|([\s\S]+?)\|\|/;
function unindent(str) {

View file

@ -3,14 +3,14 @@ const {Message} = require("@projectdysnomia/dysnomia");
const fs = require("node:fs");
const httpSignature = require("@peertube/http-signature");
const events = require("#lib/events.js");
const logger = require("#lib/logger.js");
const {hasFlag} = require("#lib/guildSettings.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const events = require("@lib/events.js");
const logger = require("@lib/logger.js");
const {hasFlag} = require("@lib/guildSettings.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {MessageFlags, ApplicationCommandOptionTypes, Permissions} = require("#util/dconstants.js");
const {getUploadLimit} = require("#util/misc.js");
const {htmlToMarkdown} = require("#util/html.js");
const {MessageFlags, ApplicationCommandOptionTypes, Permissions} = require("@util/dconstants.js");
const {getUploadLimit} = require("@util/misc.js");
const {htmlToMarkdown} = require("@util/html.js");
const FRIENDLY_USERAGENT = "HiddenPhox/fedimbed (https://gitdab.com/Cynosphere/HiddenPhox)";
@ -83,7 +83,7 @@ async function resolvePlatform(url) {
}
const keyId = "https://hf.c7.pm/actor#main-key";
const privKey = fs.readFileSync(require.resolve("#root/priv/private.pem"));
const privKey = fs.readFileSync(require.resolve("@/priv/private.pem"));
async function signedFetch(url, options) {
const urlObj = new URL(url);
@ -305,7 +305,7 @@ async function processUrl(msg, url, spoiler = false) {
avatar: postData2.account?.avatar ?? postData2.user?.avatarUrl,
};
timestamp = postData2.created_at ?? postData2.createdAt;
emotes = postData2.emojis.filter((x) => !x.name.endsWith("#.")).map((x) => ({name: `:${x.name}:`, url: x.url}));
emotes = postData2.emojis.filter((x) => !x.name.endsWith("@.")).map((x) => ({name: `:${x.name}:`, url: x.url}));
sensitive = postData2.sensitive;
const attachments = postData2.media_attachments ?? postData2.files;
@ -901,8 +901,8 @@ events.add("messageCreate", "fedimbed", async function (msg) {
.replace(/^\]\(/, "")
.replace(/\s*[\S]*?\)$/, "")
.trim()
.replace("#\u200b", "#")
.replace("#%E2%80%8B", "#");
.replace("@\u200b", "@")
.replace("@%E2%80%8B", "@");
let urlObj;
try {
urlObj = new URL(url);
@ -960,8 +960,8 @@ fedimbedCommand.callback = async function (interaction) {
.replace(/^\]\(/, "")
.replace(/\s*[\S]*?\)$/, "")
.trim()
.replace("#\u200b", "#")
.replace("#%E2%80%8B", "#");
.replace("@\u200b", "@")
.replace("@%E2%80%8B", "@");
let urlObj;
try {
urlObj = new URL(url);

View file

@ -1,11 +1,11 @@
const Command = require("#lib/command.js");
const events = require("#lib/events.js");
const logger = require("#lib/logger.js");
const Command = require("@lib/command.js");
const events = require("@lib/events.js");
const logger = require("@lib/logger.js");
const {tinycolor} = require("@ctrl/tinycolor");
const {pastelize} = require("#util/misc.js");
const {createBoardMessage} = require("#util/starboard.js");
const {pastelize} = require("@util/misc.js");
const {createBoardMessage} = require("@util/starboard.js");
const CATEGORY = "misc";
const FOXWELLS_GUILD_ID = "300436792916836352";

View file

@ -1,7 +1,7 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const CATEGORY = "general";
const {snowflakeToTimestamp} = require("#util/time.js");
const {snowflakeToTimestamp} = require("@util/time.js");
const help = new Command("help");
help.category = CATEGORY;

View file

@ -1,7 +1,7 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const CATEGORY = "image";
const {getImage} = require("#util/image.js");
const {getImage} = require("@util/image.js");
//const dumpyConvert = require("dumpy").convert;
const Jimp = require("jimp");

View file

@ -1,13 +1,12 @@
const fs = require("node:fs");
const {resolve} = require("node:path");
const logger = require("#lib/logger.js");
const logger = require("@lib/logger.js");
for (const file of fs.readdirSync(resolve(__dirname, "misc"), {withFileTypes: true})) {
if (file.isDirectory()) continue;
for (const file of fs.readdirSync(resolve(__dirname, "misc"))) {
try {
require(`#modules/misc/${file.name}`);
require(`@modules/misc/${file}`);
} catch (err) {
logger.error("hf:modules:misc", `Failed to load "${file.name}": ${err}`);
logger.error("hf:modules:misc", `Failed to load "${file}": ${err}`);
}
}

View file

@ -1,6 +1,6 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {formatTime} = require("#util/time.js");
const {formatTime} = require("@util/time.js");
const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
const anonradio = new Command("anonradio");

View file

@ -1,14 +1,14 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const {ApplicationCommandOptionTypes} = require("#util/dconstants.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {ApplicationCommandOptionTypes} = require("@util/dconstants.js");
const {safeString} = require("#util/misc.js");
const {safeString} = require("@util/misc.js");
const {tinycolor, random: randomColor} = require("@ctrl/tinycolor");
const sharp = require("sharp");
const fs = require("node:fs");
const colornamesRaw = fs.readFileSync(require.resolve("#root/data/colornames.csv"), "utf8");
const colornamesRaw = fs.readFileSync(require.resolve("@/data/colornames.csv"), "utf8");
const color = new Command("color");
color.category = "misc";

View file

@ -1,7 +1,7 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {safeString} = require("#util/misc.js");
const {formatTime} = require("#util/time.js");
const {safeString} = require("@util/misc.js");
const {formatTime} = require("@util/time.js");
const GENERATE_HEADERS = {
Accept: "application/json",

View file

@ -1,4 +1,4 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const GoogleImages = require("google-images");

View file

@ -1,5 +1,5 @@
const Command = require("#lib/command.js");
const logger = require("#lib/logger.js");
const Command = require("@lib/command.js");
const logger = require("@lib/logger.js");
const net = require("node:net");
const {resolveCname, resolveSrv} = require("node:dns/promises");

View file

@ -1,24 +0,0 @@
const Command = require("#lib/command.js");
const roll = new Command("roll");
roll.category = "misc";
roll.helpText = "Roll a dice";
roll.usage = "<sides>";
roll.addAlias("img");
roll.callback = function (msg, line) {
line = Number(line);
if (!line || line == "" || Number.isNaN(line)) line = 6;
if (line < 0) line = Math.abs(line);
if (line == 0) return ":hole:";
if (line == 1) return ":one:";
const res = Math.floor(Math.random() * line);
if (line == 2) {
return `:coin:: ${res == 1 ? "Heads" : "Tails"}`;
}
return `:game_die: (d${line}): ${1 + res}`;
};
hf.registerCommand(roll);

View file

@ -1,10 +1,10 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {ApplicationCommandOptionTypes} = require("#util/dconstants.js");
const {ApplicationCommandOptionTypes} = require("@util/dconstants.js");
const {safeString} = require("#util/misc.js");
const {parseHtmlEntities} = require("#util/html.js");
const {safeString} = require("@util/misc.js");
const {parseHtmlEntities} = require("@util/html.js");
const search = new Command("search");
search.category = "misc";

View file

@ -1,4 +1,4 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const REGEX_IPV4 = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;

View file

@ -1,10 +1,10 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {ApplicationCommandOptionTypes} = require("#util/dconstants.js");
const {Icons} = require("#util/constants.js");
const {ApplicationCommandOptionTypes} = require("@util/dconstants.js");
const {Icons} = require("@util/constants.js");
const {safeString} = require("#util/misc.js");
const {safeString} = require("@util/misc.js");
const WA_NO_ANSWER = `${Icons.silk.cross} No answer.`;

View file

@ -1,10 +1,10 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {ApplicationCommandOptionTypes} = require("#util/dconstants.js");
const {ApplicationCommandOptionTypes} = require("@util/dconstants.js");
const {safeString} = require("#util/misc.js");
const {parseHtmlEntities} = require("#util/html.js");
const {safeString} = require("@util/misc.js");
const {parseHtmlEntities} = require("@util/html.js");
const yt = new Command("youtube");
yt.addAlias("yt");

View file

@ -1,8 +1,8 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const CATEGORY = "moderation";
const {formatUsername} = require("#util/misc.js");
const {lookupUser} = require("#util/selection.js");
const {formatUsername} = require("@util/misc.js");
const {lookupUser} = require("@util/selection.js");
const tidy = new Command("tidy");
tidy.addAlias("prune");

View file

@ -3,12 +3,12 @@ const {Collection} = require("@projectdysnomia/dysnomia");
const {Readable} = require("node:stream");
const ffprobe = require("node-ffprobe");
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {formatUsername} = require("#util/misc.js");
const {formatTime} = require("#util/time.js");
const {parseHtmlEntities} = require("#util/html.js");
const {selectionMessage} = require("#util/selection.js");
const {formatUsername} = require("@util/misc.js");
const {formatTime} = require("@util/time.js");
const {parseHtmlEntities} = require("@util/html.js");
const {selectionMessage} = require("@util/selection.js");
const REGEX_YOUTUBE = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/.+$/;
const REGEX_YOUTUBE_PLAYLIST = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.?be)\/playlist\?list=(.+)$/;

View file

@ -10,15 +10,15 @@ private_reminders.json example:
]
*/
const timer = require("#lib/timer.js");
const logger = require("#lib/logger.js");
const timer = require("@lib/timer");
const logger = require("@lib/logger");
const tzFormatterCache = {};
const dmCache = {};
let reminderData;
try {
reminderData = require("#root/private_reminders.json");
reminderData = require("@/private_reminders.json");
} catch {
return;
}

View file

@ -1,6 +1,6 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {selectionMessage} = require("#util/selection.js");
const {selectionMessage} = require("@util/selection.js");
hf.database.run(
"CREATE TABLE IF NOT EXISTS roleme (guild TEXT NOT NULL PRIMARY KEY, roles TEXT NOT NULL) WITHOUT ROWID"

View file

@ -1,13 +1,12 @@
const fs = require("node:fs");
const {resolve} = require("node:path");
const logger = require("#lib/logger.js");
const logger = require("@lib/logger.js");
for (const file of fs.readdirSync(resolve(__dirname, "utility"), {withFileTypes: true})) {
if (file.isDirectory()) continue;
for (const file of fs.readdirSync(resolve(__dirname, "utility"))) {
try {
require(`#modules/utility/${file.name}`);
require(`@modules/utility/${file}`);
} catch (err) {
logger.error("hf:modules:utility", `Failed to load "${file.name}": ${err}`);
logger.error("hf:modules:utility", `Failed to load "${file}": ${err}`);
}
}

View file

@ -1,5 +1,5 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {
APIEndpoints,
@ -8,14 +8,14 @@ const {
ApplicationTypes,
CDNEndpoints,
Games,
} = require("#util/dconstants.js");
} = require("@util/dconstants.js");
const {
ApplicationFlagNames,
Icons,
RegExp: {Snowflake: SNOWFLAKE_REGEX},
} = require("#util/constants.js");
const {snowflakeToTimestamp} = require("#util/time.js");
const {getGuild, safeString, formatUsername, flagsFromInt} = require("#util/misc.js");
} = require("@util/constants.js");
const {snowflakeToTimestamp} = require("@util/time.js");
const {getGuild, safeString, formatUsername, flagsFromInt} = require("@util/misc.js");
const appinfo = new Command("appinfo");
appinfo.category = "utility";

View file

@ -1,10 +1,10 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {APIEndpoints, CDNEndpoints} = require("#util/dconstants.js");
const {Icons} = require("#util/constants.js");
const {APIEndpoints, CDNEndpoints} = require("@util/dconstants.js");
const {Icons} = require("@util/constants.js");
const {formatUsername, getDefaultAvatar} = require("#util/misc.js");
const {lookupUser} = require("#util/selection.js");
const {formatUsername, getDefaultAvatar} = require("@util/misc.js");
const {lookupUser} = require("@util/selection.js");
const avatar = new Command("avatar");
avatar.category = "utility";
@ -48,7 +48,7 @@ avatar.callback = async function (msg, line, [user], {server, guild}) {
}
} else if (user) {
const lookup = await lookupUser(msg, user);
if (typeof lookup === "string") {
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
return lookup;
} else {
id = lookup.id;

View file

@ -1,9 +1,9 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {APIEndpoints, CDNEndpoints} = require("#util/dconstants.js");
const {APIEndpoints, CDNEndpoints} = require("@util/dconstants.js");
const {formatUsername} = require("#util/misc.js");
const {lookupUser} = require("#util/selection.js");
const {formatUsername} = require("@util/misc.js");
const {lookupUser} = require("@util/selection.js");
const banner = new Command("banner");
banner.category = "utility";
@ -44,7 +44,7 @@ banner.callback = async function (msg, line, [user], {server, guild}) {
}
} else if (user) {
const lookup = await lookupUser(msg, user);
if (typeof lookup === "string") {
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
return lookup;
} else {
id = lookup.id;

View file

@ -1,8 +1,8 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {ApplicationCommandOptionTypes} = require("#util/dconstants.js");
const {getNamesFromString} = require("#util/unicode.js");
const {ApplicationCommandOptionTypes} = require("@util/dconstants.js");
const {getNamesFromString} = require("@util/unicode.js");
const charinfo = new Command("charinfo");
charinfo.category = "utility";

View file

@ -1,9 +1,9 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {APIEndpoints, CDNEndpoints} = require("#util/dconstants.js");
const {APIEndpoints, CDNEndpoints} = require("@util/dconstants.js");
const {formatUsername} = require("#util/misc.js");
const {lookupUser} = require("#util/selection.js");
const {formatUsername} = require("@util/misc.js");
const {lookupUser} = require("@util/selection.js");
const decoration = new Command("decoration");
decoration.category = "utility";
@ -15,7 +15,7 @@ decoration.callback = async function (msg, line, [user]) {
if (user) {
const lookup = await lookupUser(msg, user);
if (typeof lookup === "string") {
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
return lookup;
} else {
id = lookup.id;

View file

@ -1,10 +1,10 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {APIEndpoints, UserFlags} = require("#util/dconstants.js");
const {APIEndpoints, UserFlags} = require("@util/dconstants.js");
const {
RegExp: {Snowflake: SNOWFLAKE_REGEX},
} = require("#util/constants.js");
const {flagsFromInt, formatUsername} = require("#util/misc.js");
} = require("@util/constants.js");
const {flagsFromInt, formatUsername} = require("@util/misc.js");
const _UserFlags = Object.entries(UserFlags).filter(([name]) => name != "NONE");
for (const set of _UserFlags) {
@ -14,8 +14,6 @@ for (const set of _UserFlags) {
}
const UserFlagsMapped = Object.fromEntries(_UserFlags.map((x) => x.reverse()));
const REGEX_MENTION = /<@!?(\d+)>/;
const flagdump = new Command("flagdump");
flagdump.category = "utility";
flagdump.helpText = "Dumps Discord user flags.";
@ -36,29 +34,26 @@ flagdump.callback = async function (msg, line, [numOrMention], {id, list}) {
if (UserFlagsMapped[index] == undefined) continue;
allFlags += 1n << BigInt(index);
}
out = `All flags:\n\`\`\`\n${flagsFromInt(allFlags, UserFlagsMapped)}\`\`\``;
} else if (REGEX_MENTION.test(numOrMention) || SNOWFLAKE_REGEX.test(id)) {
const targetId = id ?? numOrMention.match(REGEX_MENTION)?.[1];
out = `All flags:\n\`\`\`${flagsFromInt(allFlags, UserFlagsMapped)}\`\`\``;
} else if (/<@!?(\d+)>/.test(numOrMention) || SNOWFLAKE_REGEX.test(id)) {
const targetId = id ?? numOrMention.match(/<@!?(\d+)>/)?.[1];
if (!targetId) return "Got null ID.";
let user;
try {
user = await hf.bot.requestHandler.request("GET", APIEndpoints.USER(targetId), true);
} catch (err) {
if (err.code == 10013) return "Unknown user";
}
let user = hf.bot.users.get(targetId);
if (!user) user = await hf.bot.requestHandler.request("GET", APIEndpoints.USER(targetId), true).catch(() => {});
if (!user) {
out = "Failed to get user.";
} else {
out = `\`${formatUsername(user)}\`'s public flags:\n\`\`\`\n${flagsFromInt(
user.public_flags,
out = `\`${formatUsername(user)}\`'s public flags:\n\`\`\`${flagsFromInt(
user.public_flags ?? user.publicFlags,
UserFlagsMapped
)}\`\`\``;
}
} else if (!Number.isNaN(num)) {
out = `\`\`\`\n${flagsFromInt(num, UserFlagsMapped)}\`\`\``;
} else {
out = `\`${formatUsername(msg.author)}\`'s public flags:\n\`\`\`\n${flagsFromInt(
out = `\`${formatUsername(msg.author)}\`'s public flags:\n\`\`\`${flagsFromInt(
msg.author.publicFlags,
UserFlagsMapped
)}\`\`\``;

View file

@ -1,5 +1,5 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {VoiceChannel} = require("@projectdysnomia/dysnomia");
@ -12,14 +12,14 @@ const {
Games,
Permissions,
VerificationLevelStrings,
} = require("#util/dconstants.js");
} = require("@util/dconstants.js");
const {
RegExp: {Snowflake: SNOWFLAKE_REGEX},
Icons,
ChannelTypeNames,
} = require("#util/constants.js");
const {snowflakeToTimestamp} = require("#util/time.js");
const {getGuild, tryGetGuild, formatGuildFeatures} = require("#util/misc.js");
} = require("@util/constants.js");
const {snowflakeToTimestamp} = require("@util/time.js");
const {getGuild, tryGetGuild, formatGuildFeatures} = require("@util/misc.js");
const guildinfo = new Command("guildinfo");
guildinfo.category = "utility";

View file

@ -1,5 +1,5 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const sharp = require("sharp");
@ -7,9 +7,9 @@ const {
RegExp: {Emote: CUSTOM_EMOTE_REGEX},
EmojiSets,
EmojiNames,
} = require("#util/constants.js");
const {ApplicationCommandOptionTypes, CDNEndpoints} = require("#util/dconstants.js");
const {getNamesFromString} = require("#util/unicode.js");
} = require("@util/constants.js");
const {ApplicationCommandOptionTypes, CDNEndpoints} = require("@util/dconstants.js");
const {getNamesFromString} = require("@util/unicode.js");
const jumbo = new Command("jumbo");
jumbo.category = "utility";

View file

@ -1,16 +1,16 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {
APIEndpoints,
ApplicationCommandOptionTypes,
CDNEndpoints,
DEFAULT_GROUP_DM_AVATARS,
} = require("#util/dconstants.js");
const {Icons} = require("#util/constants.js");
} = require("@util/dconstants.js");
const {Icons} = require("@util/constants.js");
const {formatUsername, safeString, formatGuildFeatures} = require("#util/misc.js");
const {snowflakeToTimestamp} = require("#util/time.js");
const {formatUsername, safeString, formatGuildFeatures} = require("@util/misc.js");
const {snowflakeToTimestamp} = require("@util/time.js");
const lookupinvite = new Command("lookupinvite");
lookupinvite.category = "utility";

View file

@ -1,9 +1,9 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {APIEndpoints} = require("#util/dconstants.js");
const {APIEndpoints} = require("@util/dconstants.js");
const {
RegExp: {Pomelo: POMELO_REGEX},
} = require("#util/constants.js");
} = require("@util/constants.js");
const pomelo = new Command("pomelo");
pomelo.category = "utility";

View file

@ -1,12 +1,12 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const sharp = require("sharp");
const {ActivityTypeNames, CDNEndpoints, Games, HangStatusStrings, HANG_STATUS_ICONS} = require("#util/dconstants.js");
const {Icons} = require("#util/constants.js");
const {formatUsername} = require("#util/misc.js");
const {lookupUser} = require("#util/selection.js");
const {formatTime} = require("#util/time.js");
const {ActivityTypeNames, CDNEndpoints, Games, HangStatusStrings, HANG_STATUS_ICONS} = require("@util/dconstants.js");
const {Icons} = require("@util/constants.js");
const {formatUsername} = require("@util/misc.js");
const {lookupUser} = require("@util/selection.js");
const {formatTime} = require("@util/time.js");
const HangStatusImages = {};
(async () => {
@ -52,7 +52,7 @@ presence.callback = async function (msg, line) {
let target;
if (line) {
const user = await lookupUser(msg, line);
if (typeof user === "string") {
if (user == "No results" || user == "Canceled" || user == "Request timed out") {
return user;
} else {
let member = user;

View file

@ -1,6 +1,6 @@
const Command = require("#lib/command.js");
const Command = require("@lib/command.js");
const {snowflakeToTimestamp} = require("#util/time.js");
const {snowflakeToTimestamp} = require("@util/time.js");
const snowflake = new Command("snowflake");
snowflake.category = "utility";

View file

@ -1,5 +1,5 @@
const Command = require("#lib/command.js");
const InteractionCommand = require("#lib/interactionCommand.js");
const Command = require("@lib/command.js");
const InteractionCommand = require("@lib/interactionCommand.js");
const {
ActivityTypeNames,
@ -10,12 +10,12 @@ const {
CDNEndpoints,
ClanPlaystyle,
UserFlags,
} = require("#util/dconstants.js");
const {Icons} = require("#util/constants.js");
} = require("@util/dconstants.js");
const {Icons} = require("@util/constants.js");
const {formatUsername, getDefaultAvatar, getTopColor, pastelize} = require("#util/misc.js");
const {snowflakeToTimestamp} = require("#util/time.js");
const {lookupUser} = require("#util/selection.js");
const {formatUsername, getDefaultAvatar, getTopColor, pastelize} = require("@util/misc.js");
const {snowflakeToTimestamp} = require("@util/time.js");
const {lookupUser} = require("@util/selection.js");
const ONE_MONTH = 2628000;
@ -70,7 +70,7 @@ userinfo.callback = async function (msg, line) {
id = msg.author?.id ?? msg.user?.id;
} else {
const lookup = await lookupUser(msg, line);
if (typeof lookup === "string") {
if (lookup == "No results" || lookup == "Canceled" || lookup == "Request timed out") {
return lookup;
} else {
id = lookup.id;

View file

@ -546,7 +546,7 @@ EMOJI_SETS.twitter = EMOJI_SETS.twemoji;
//EMOJI_SETS.fb = EMOJI_SETS.facebook;
module.exports.EmojiSets = EMOJI_SETS;
const EmojiData = require("#root/data/emoji.json");
const EmojiData = require("@/data/emoji.json");
const EMOJI_NAMES = [];
for (const emoji of EmojiData) {
EMOJI_NAMES[emoji.char] = emoji.name.replace(/ /g, "_");

View file

@ -130,7 +130,7 @@ module.exports.DEFAULT_GROUP_DM_AVATARS = [
module.exports.ExplicitContentFilterStrings = ["Disabled", "Members without roles", "All members"];
module.exports.Games = require("#root/data/games.json");
module.exports.Games = require("@/data/games.json");
module.exports.HANG_STATUS_ICONS = Object.fromEntries(
Object.entries({

View file

@ -2,7 +2,7 @@ const murmurhash = require("murmurhash").v3;
const {tinycolor} = require("@ctrl/tinycolor");
const {APIEndpoints, CDNEndpoints, UPLOAD_LIMIT, UPLOAD_LIMIT_TIER_2, UPLOAD_LIMIT_TIER_3} = require("./dconstants.js");
const {GuildFeaturesFormatted, Icons} = require("#util/constants.js");
const {GuildFeaturesFormatted, Icons} = require("@util/constants.js");
function pastelize(id) {
const hue = murmurhash(id) % 360;
@ -35,7 +35,7 @@ function safeString(string, newLines = true) {
string = string ? string.toString() : "";
string = string.replace(/`/g, "'");
string = string.replace(/<@/g, "<@\u200b");
string = string.replace(/<#root/g, "<#\u200b");
string = string.replace(/<#/g, "<#\u200b");
string = string.replace(/<&/g, "<&\u200b");
if (newLines) string = string.replace(/\n/g, " ");
return string;

View file

@ -1,11 +1,11 @@
const {Collection} = require("@projectdysnomia/dysnomia");
const logger = require("#lib/logger.js");
const {formatUsername} = require("#util/misc.js");
const {APIEndpoints} = require("#util/dconstants.js");
const logger = require("@lib/logger.js");
const {formatUsername} = require("@util/misc.js");
const {APIEndpoints} = require("@util/dconstants.js");
const {
RegExp: {Snowflake: REGEX_SNOWFLAKE},
} = require("#util/constants.js");
} = require("@util/constants.js");
if (!hf.selectionMessages) hf.selectionMessages = new Collection();
async function selectionMessage(msg, heading, options, timeout = 30000, maxItems = 1) {
@ -112,11 +112,7 @@ async function selectionMessage(msg, heading, options, timeout = 30000, maxItems
async function lookupUser(msg, str, filter) {
if (REGEX_SNOWFLAKE.test(str)) {
try {
return await hf.bot.requestHandler.request("GET", APIEndpoints.USER(str.match(REGEX_SNOWFLAKE)[1]), true);
} catch (err) {
return err.message;
}
}
let users;

View file

@ -1,5 +1,5 @@
const {pastelize} = require("#util/misc.js");
const {findSuitableImage} = require("#util/image.js");
const {pastelize} = require("@util/misc.js");
const {findSuitableImage} = require("@util/image.js");
async function createBoardMessage(msg, count, threadId = null, fetchAttachment = true) {
const name = msg.member?.nick ?? msg.author.globalName ?? msg.author.username;