flagdump: hopefully fix --id
This commit is contained in:
parent
ff6a382591
commit
042f42e02e
1 changed files with 14 additions and 9 deletions
|
@ -14,6 +14,8 @@ 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.";
|
||||
|
@ -34,26 +36,29 @@ flagdump.callback = async function (msg, line, [numOrMention], {id, list}) {
|
|||
if (UserFlagsMapped[index] == undefined) continue;
|
||||
allFlags += 1n << BigInt(index);
|
||||
}
|
||||
out = `All flags:\n\`\`\`${flagsFromInt(allFlags, UserFlagsMapped)}\`\`\``;
|
||||
} else if (/<@!?(\d+)>/.test(numOrMention) || SNOWFLAKE_REGEX.test(id)) {
|
||||
const targetId = id ?? numOrMention.match(/<@!?(\d+)>/)?.[1];
|
||||
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];
|
||||
if (!targetId) return "Got null ID.";
|
||||
let user = hf.bot.users.get(targetId);
|
||||
|
||||
if (!user) user = await hf.bot.requestHandler.request("GET", APIEndpoints.USER(targetId), true).catch(() => {});
|
||||
let user;
|
||||
try {
|
||||
user = await hf.bot.requestHandler.request("GET", APIEndpoints.USER(targetId), true);
|
||||
} catch (err) {
|
||||
if (err.code == 10013) return "Unknown user";
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
out = "Failed to get user.";
|
||||
} else {
|
||||
out = `\`${formatUsername(user)}\`'s public flags:\n\`\`\`${flagsFromInt(
|
||||
user.public_flags ?? user.publicFlags,
|
||||
out = `\`${formatUsername(user)}\`'s public flags:\n\`\`\`\n${flagsFromInt(
|
||||
user.public_flags,
|
||||
UserFlagsMapped
|
||||
)}\`\`\``;
|
||||
}
|
||||
} else if (!Number.isNaN(num)) {
|
||||
out = `\`\`\`\n${flagsFromInt(num, UserFlagsMapped)}\`\`\``;
|
||||
} else {
|
||||
out = `\`${formatUsername(msg.author)}\`'s public flags:\n\`\`\`${flagsFromInt(
|
||||
out = `\`${formatUsername(msg.author)}\`'s public flags:\n\`\`\`\n${flagsFromInt(
|
||||
msg.author.publicFlags,
|
||||
UserFlagsMapped
|
||||
)}\`\`\``;
|
||||
|
|
Loading…
Reference in a new issue