be smarter
This commit is contained in:
parent
1497758905
commit
cac9ff8db0
4 changed files with 48 additions and 169 deletions
|
@ -19,7 +19,7 @@ const {
|
||||||
ChannelTypeNames,
|
ChannelTypeNames,
|
||||||
} = require("#util/constants.js");
|
} = require("#util/constants.js");
|
||||||
const {snowflakeToTimestamp} = require("#util/time.js");
|
const {snowflakeToTimestamp} = require("#util/time.js");
|
||||||
const {getGuild, tryGetGuild, formatGuildFeatures} = require("#util/misc.js");
|
const {getGuild, tryGetGuild, formatGuildFeatures, makeGuildFeatureFields} = require("#util/misc.js");
|
||||||
|
|
||||||
const guildinfo = new Command("guildinfo");
|
const guildinfo = new Command("guildinfo");
|
||||||
guildinfo.category = "utility";
|
guildinfo.category = "utility";
|
||||||
|
@ -367,39 +367,7 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
inline: false,
|
inline: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const features = formatGuildFeatures(guild.features);
|
embed.fields.push(...makeGuildFeatureFields(formatGuildFeatures(guild.features)));
|
||||||
|
|
||||||
if (features.length > 0) {
|
|
||||||
let featuresList = "";
|
|
||||||
let firstFeature = true;
|
|
||||||
for (let index = 0; index < features.length; index++) {
|
|
||||||
const feature = features[index];
|
|
||||||
if (featuresList.length + feature.length + 1 > 1024) {
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
if (firstFeature === true) firstFeature = false;
|
|
||||||
if (index === features.length - 1)
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else if (index === features.length - 1) {
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
featuresList += feature + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const images = [];
|
const images = [];
|
||||||
if (guild.icon) {
|
if (guild.icon) {
|
||||||
|
@ -479,39 +447,7 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
inline: false,
|
inline: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const features = formatGuildFeatures(guild.features);
|
embed.fields.push(...makeGuildFeatureFields(formatGuildFeatures(guild.features)));
|
||||||
|
|
||||||
if (features.length > 0) {
|
|
||||||
let featuresList = "";
|
|
||||||
let firstFeature = true;
|
|
||||||
for (let index = 0; index < features.length; index++) {
|
|
||||||
const feature = features[index];
|
|
||||||
if (featuresList.length + feature.length + 1 > 1024) {
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
if (firstFeature === true) firstFeature = false;
|
|
||||||
if (index === features.length - 1)
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else if (index === features.length - 1) {
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
featuresList += feature + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const images = [];
|
const images = [];
|
||||||
if (guild.icon) {
|
if (guild.icon) {
|
||||||
|
@ -595,39 +531,7 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (invite?.guild?.features) {
|
if (invite?.guild?.features) {
|
||||||
const features = formatGuildFeatures(invite.guild.features);
|
embed.fields.push(...makeGuildFeatureFields(formatGuildFeatures(invite.guild.features)));
|
||||||
|
|
||||||
if (features.length > 0) {
|
|
||||||
let featuresList = "";
|
|
||||||
let firstFeature = true;
|
|
||||||
for (let index = 0; index < features.length; index++) {
|
|
||||||
const feature = features[index];
|
|
||||||
if (featuresList.length + feature.length + 1 > 1024) {
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
if (firstFeature === true) firstFeature = false;
|
|
||||||
if (index === features.length - 1)
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else if (index === features.length - 1) {
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
featuresList += feature + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const images = [];
|
const images = [];
|
||||||
|
@ -695,39 +599,7 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
|
||||||
inline: false,
|
inline: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const features = formatGuildFeatures(invite.guild.features);
|
embed.fields.push(...makeGuildFeatureFields(formatGuildFeatures(guild.features)));
|
||||||
|
|
||||||
if (features.length > 0) {
|
|
||||||
let featuresList = "";
|
|
||||||
let firstFeature = true;
|
|
||||||
for (let index = 0; index < features.length; index++) {
|
|
||||||
const feature = features[index];
|
|
||||||
if (featuresList.length + feature.length + 1 > 1024) {
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
if (firstFeature === true) firstFeature = false;
|
|
||||||
if (index === features.length - 1)
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else if (index === features.length - 1) {
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
featuresList += feature + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const images = [];
|
const images = [];
|
||||||
if (invite.guild.icon) {
|
if (invite.guild.icon) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ const {
|
||||||
} = require("#util/dconstants.js");
|
} = require("#util/dconstants.js");
|
||||||
const {Icons} = require("#util/constants.js");
|
const {Icons} = require("#util/constants.js");
|
||||||
|
|
||||||
const {formatUsername, safeString, formatGuildFeatures} = require("#util/misc.js");
|
const {formatUsername, safeString, formatGuildFeatures, makeGuildFeatureFields} = require("#util/misc.js");
|
||||||
const {snowflakeToTimestamp} = require("#util/time.js");
|
const {snowflakeToTimestamp} = require("#util/time.js");
|
||||||
|
|
||||||
const lookupinvite = new Command("lookupinvite");
|
const lookupinvite = new Command("lookupinvite");
|
||||||
|
@ -120,38 +120,7 @@ lookupinvite.callback = async function (msg, line) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (invite.guild.features) {
|
if (invite.guild.features) {
|
||||||
const features = formatGuildFeatures(invite.guild.features);
|
embed.fields.push(...makeGuildFeatureFields(formatGuildFeatures(invite.guild.features)));
|
||||||
if (features.length > 0) {
|
|
||||||
let featuresList = "";
|
|
||||||
let firstFeature = true;
|
|
||||||
for (let index = 0; index < features.length; index++) {
|
|
||||||
const feature = features[index];
|
|
||||||
if (featuresList.length + feature.length + 1 > 1024) {
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
if (firstFeature === true) firstFeature = false;
|
|
||||||
if (index === features.length - 1)
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else if (index === features.length - 1) {
|
|
||||||
featuresList = feature + "\n";
|
|
||||||
embed.fields.push({
|
|
||||||
name: firstFeature ? `Features (${features.length})` : "\u200b",
|
|
||||||
value: featuresList.trim(),
|
|
||||||
inline: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
featuresList += feature + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const guildIcon = invite.guild?.icon && CDNEndpoints.GUILD_ICON(invite.guild.id, invite.guild.icon);
|
const guildIcon = invite.guild?.icon && CDNEndpoints.GUILD_ICON(invite.guild.id, invite.guild.icon);
|
||||||
|
|
|
@ -416,16 +416,16 @@ module.exports.GuildFeaturesFormatted = {
|
||||||
SOUNDBOARD: {icon: SILK_ICONS.sound},
|
SOUNDBOARD: {icon: SILK_ICONS.sound},
|
||||||
STAGE_CHANNEL_VIEWERS_50: {
|
STAGE_CHANNEL_VIEWERS_50: {
|
||||||
icon: SILK_ICONS.transmit_blue,
|
icon: SILK_ICONS.transmit_blue,
|
||||||
name: "Stages: 50 Viewers",
|
name: "Stages: 50 Users",
|
||||||
},
|
},
|
||||||
STAGE_CHANNEL_VIEWERS_150: {
|
STAGE_CHANNEL_VIEWERS_150: {
|
||||||
icon: SILK_ICONS.transmit_blue,
|
icon: SILK_ICONS.transmit_blue,
|
||||||
name: "Stages: 150 Viewers",
|
name: "Stages: 150 Users",
|
||||||
},
|
},
|
||||||
SUMMARIES_ENABLED: {icon: SILK_ICONS.book_tabs, deprecated: true},
|
SUMMARIES_ENABLED: {icon: SILK_ICONS.book_tabs, deprecated: true},
|
||||||
SUMMARIES_ENABLED_GA: {
|
SUMMARIES_ENABLED_GA: {
|
||||||
icon: SILK_ICONS.book_tabs,
|
icon: SILK_ICONS.book_tabs,
|
||||||
name: "Summaries (General Access)",
|
name: "Summaries: General Access",
|
||||||
},
|
},
|
||||||
SUMMARIES_DISABLED_BY_USER: {
|
SUMMARIES_DISABLED_BY_USER: {
|
||||||
icon: SILK_ICONS.book_tabs_delete,
|
icon: SILK_ICONS.book_tabs_delete,
|
||||||
|
|
|
@ -177,6 +177,43 @@ function formatGuildFeatures(features) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeGuildFeatureFields(features) {
|
||||||
|
const fields = [];
|
||||||
|
if (features.length > 0) {
|
||||||
|
let featuresList = "";
|
||||||
|
let firstFeature = true;
|
||||||
|
for (let index = 0; index < features.length; index++) {
|
||||||
|
const feature = features[index];
|
||||||
|
const fieldName = firstFeature ? `Features (${features.length})` : "\u200b";
|
||||||
|
if (featuresList.length + feature.length + 1 > 1024) {
|
||||||
|
fields.push({
|
||||||
|
name: fieldName,
|
||||||
|
value: featuresList.trim(),
|
||||||
|
inline: true,
|
||||||
|
});
|
||||||
|
featuresList = feature + "\n";
|
||||||
|
if (firstFeature === true) firstFeature = false;
|
||||||
|
if (index === features.length - 1)
|
||||||
|
fields.push({
|
||||||
|
name: fieldName,
|
||||||
|
value: featuresList.trim(),
|
||||||
|
inline: true,
|
||||||
|
});
|
||||||
|
} else if (index === features.length - 1) {
|
||||||
|
featuresList += feature + "\n";
|
||||||
|
fields.push({
|
||||||
|
name: fieldName,
|
||||||
|
value: featuresList.trim(),
|
||||||
|
inline: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
featuresList += feature + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
function getDefaultAvatar(id, discriminator = null, size = 4096) {
|
function getDefaultAvatar(id, discriminator = null, size = 4096) {
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
|
@ -225,6 +262,7 @@ module.exports = {
|
||||||
tryGetGuild,
|
tryGetGuild,
|
||||||
enumKeyToName,
|
enumKeyToName,
|
||||||
formatGuildFeatures,
|
formatGuildFeatures,
|
||||||
|
makeGuildFeatureFields,
|
||||||
getDefaultAvatar,
|
getDefaultAvatar,
|
||||||
flagsFromInt,
|
flagsFromInt,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue