utility.guildinfo: add --debug
This commit is contained in:
parent
703a92383a
commit
db80e182cc
1 changed files with 24 additions and 2 deletions
|
@ -18,7 +18,7 @@ const {
|
|||
ChannelTypeNames,
|
||||
} = require("../../util/constants.js");
|
||||
const {snowflakeToTimestamp} = require("../../util/time.js");
|
||||
const {getGuild, formatGuildFeatures} = require("../../util/misc.js");
|
||||
const {getGuild, tryGetGuild, formatGuildFeatures} = require("../../util/misc.js");
|
||||
|
||||
const guildinfo = new Command("guildinfo");
|
||||
guildinfo.category = "utility";
|
||||
|
@ -31,7 +31,7 @@ guildinfo.addAlias("serverinfo");
|
|||
guildinfo.addAlias("server");
|
||||
guildinfo.addAlias("sinfo");
|
||||
guildinfo.addAlias("si");
|
||||
guildinfo.callback = async function (msg, line, args, {nolocal}) {
|
||||
guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||
let _guild, clanEmbed, id;
|
||||
if (!line || line == "") {
|
||||
if (!msg.guildID) return "Not in a guild.";
|
||||
|
@ -42,6 +42,28 @@ guildinfo.callback = async function (msg, line, args, {nolocal}) {
|
|||
_guild = await getGuild(msg.guildID);
|
||||
}
|
||||
id = msg.guildID;
|
||||
} else if (debug) {
|
||||
if (!SNOWFLAKE_REGEX.test(line)) return "Not a snowflake.";
|
||||
id = line.match(SNOWFLAKE_REGEX)[1];
|
||||
|
||||
try {
|
||||
await hf.bot.requestHandler.request("GET", APIEndpoints.GUILD_WIDGET(id), false);
|
||||
} catch (err) {
|
||||
if (err.code != 50004) {
|
||||
return "Guild not found.";
|
||||
}
|
||||
}
|
||||
|
||||
const sources = await tryGetGuild(id);
|
||||
|
||||
return `\`\`\`js
|
||||
"local": ${sources.local}
|
||||
"preview": ${sources.preview}${sources.local && sources.preview ? " // false positive, local = true" : ""}
|
||||
"widget": ${sources.widget}
|
||||
"discovery": ${sources.discovery}
|
||||
"verification": ${sources.verification}
|
||||
"clan": ${sources.clan}
|
||||
\`\`\``;
|
||||
} else {
|
||||
if (!SNOWFLAKE_REGEX.test(line)) return "Not a snowflake.";
|
||||
const snowflake = line.match(SNOWFLAKE_REGEX)[1];
|
||||
|
|
Loading…
Reference in a new issue