utility.guildinfo: fix widget invite lookup
This commit is contained in:
parent
14b526ca55
commit
6e68754ecb
1 changed files with 19 additions and 6 deletions
|
@ -5,6 +5,7 @@ const CATEGORY = "utility";
|
||||||
|
|
||||||
const sharp = require("sharp");
|
const sharp = require("sharp");
|
||||||
const {Constants, VoiceChannel} = require("@projectdysnomia/dysnomia");
|
const {Constants, VoiceChannel} = require("@projectdysnomia/dysnomia");
|
||||||
|
const Endpoints = require("@projectdysnomia/dysnomia/lib/rest/Endpoints.js");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
formatTime,
|
formatTime,
|
||||||
|
@ -764,7 +765,9 @@ lookupinvite.callback = async function (msg, line) {
|
||||||
return "No arguments passed.";
|
return "No arguments passed.";
|
||||||
}
|
}
|
||||||
|
|
||||||
line = line.replace(/(https?:\/\/)?discord\.gg\//, "");
|
line = line.replace(/(https?:\/\/)?discord(\.gg|(app)?.com\/invites)\//, "");
|
||||||
|
|
||||||
|
if (decodeURI(line).indexOf("../") > -1) return "nuh uh";
|
||||||
|
|
||||||
let bail = false;
|
let bail = false;
|
||||||
let error;
|
let error;
|
||||||
|
@ -1052,9 +1055,9 @@ flagdump.callback = async function (msg, line, [numOrMention], {id, list}) {
|
||||||
}
|
}
|
||||||
return `All flags:\n\`\`\`${flagsFromInt(allFlags, USER_FLAGS)}\`\`\``;
|
return `All flags:\n\`\`\`${flagsFromInt(allFlags, USER_FLAGS)}\`\`\``;
|
||||||
} else if (/<@!?(\d+)>/.test(numOrMention) || !isNaN(id)) {
|
} else if (/<@!?(\d+)>/.test(numOrMention) || !isNaN(id)) {
|
||||||
const targetId = id || numOrMention.match(/<@!?(\d+)>/)?.[1];
|
const targetId = id ?? numOrMention.match(/<@!?(\d+)>/)?.[1];
|
||||||
if (!targetId) return "Got null ID.";
|
if (!targetId) return "Got null ID.";
|
||||||
const guild = msg.channel.guild || hf.bot.guilds.get(msg.guildID);
|
const guild = msg.channel.guild ?? hf.bot.guilds.get(msg.guildID);
|
||||||
let user = guild && (await guild.fetchMembers({userIDs: [targetId]}));
|
let user = guild && (await guild.fetchMembers({userIDs: [targetId]}));
|
||||||
if (!user || !user[0]) {
|
if (!user || !user[0]) {
|
||||||
user = hf.bot.users.get(id);
|
user = hf.bot.users.get(id);
|
||||||
|
@ -1062,11 +1065,18 @@ flagdump.callback = async function (msg, line, [numOrMention], {id, list}) {
|
||||||
user = user[0].user;
|
user = user[0].user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!user)
|
||||||
|
user = await hf.bot.requestHandler.request(
|
||||||
|
"GET",
|
||||||
|
Endpoints.USER(id),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return "User not cached.";
|
return "Failed to get user.";
|
||||||
} else {
|
} else {
|
||||||
return `\`${formatUsername(user)}\`'s public flags:\n\`\`\`${flagsFromInt(
|
return `\`${formatUsername(user)}\`'s public flags:\n\`\`\`${flagsFromInt(
|
||||||
user.publicFlags,
|
user.public_flags ?? user.publicFlags,
|
||||||
USER_FLAGS
|
USER_FLAGS
|
||||||
)}\`\`\``;
|
)}\`\`\``;
|
||||||
}
|
}
|
||||||
|
@ -2356,7 +2366,10 @@ guildinfo.callback = async function (msg, line) {
|
||||||
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}?with_counts=true&with_expiration=true`
|
`/invites/${guild.instant_invite.replace(
|
||||||
|
/(https?:\/\/)?discord(\.gg|(app)?.com\/invites)\//,
|
||||||
|
""
|
||||||
|
)}?with_counts=true&with_expiration=true`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue