utility.flagdump: pass right id var
This commit is contained in:
parent
2aab3ad9fa
commit
df4dc6be54
1 changed files with 7 additions and 4 deletions
|
@ -1,6 +1,9 @@
|
|||
const Command = require("../../lib/command.js");
|
||||
|
||||
const {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");
|
||||
|
||||
const _UserFlags = Object.entries(UserFlags).filter(([name]) => name != "NONE");
|
||||
|
@ -26,12 +29,12 @@ flagdump.callback = async function (msg, line, [numOrMention], {id, list}) {
|
|||
allFlags += 1n << BigInt(index);
|
||||
}
|
||||
return `All flags:\n\`\`\`${flagsFromInt(allFlags, UserFlagsMapped)}\`\`\``;
|
||||
} else if (/<@!?(\d+)>/.test(numOrMention) || !isNaN(id)) {
|
||||
} else if (/<@!?(\d+)>/.test(numOrMention) || SNOWFLAKE_REGEX.test(id)) {
|
||||
const targetId = id ?? numOrMention.match(/<@!?(\d+)>/)?.[1];
|
||||
if (!targetId) return "Got null ID.";
|
||||
let user = hf.bot.users.get(id);
|
||||
let user = hf.bot.users.get(targetId);
|
||||
|
||||
if (!user) user = await hf.bot.requestHandler.request("GET", `/users/${id}`, true).catch(() => {});
|
||||
if (!user) user = await hf.bot.requestHandler.request("GET", APIEndpoints.USER(targetId), true).catch(() => {});
|
||||
|
||||
if (!user) {
|
||||
return "Failed to get user.";
|
||||
|
|
Loading…
Reference in a new issue