Compare commits
2 commits
8e7bd2a1d9
...
f54ec82c99
Author | SHA1 | Date | |
---|---|---|---|
f54ec82c99 | |||
83c0b226eb |
2 changed files with 25 additions and 22 deletions
|
@ -2,6 +2,7 @@ const {ApplicationCommandOptionTypes, MessageFlags} = require("#util/dconstants.
|
||||||
const InteractionCommand = require("#lib/interactionCommand.js");
|
const InteractionCommand = require("#lib/interactionCommand.js");
|
||||||
|
|
||||||
const events = require("#lib/events.js");
|
const events = require("#lib/events.js");
|
||||||
|
const logger = require("#lib/logger.js");
|
||||||
const {hasFlag} = require("#lib/guildSettings.js");
|
const {hasFlag} = require("#lib/guildSettings.js");
|
||||||
const REGEX_GITHUB =
|
const REGEX_GITHUB =
|
||||||
/(?:\s|^)(\|\|\s*)?https?:\/\/(www\.)?github\.com\/[a-z0-9-]+\/[a-z0-9-._]+\/blob\/([a-z0-9-_.?&=#root/%]*)(\s*\|\|)?/gi;
|
/(?:\s|^)(\|\|\s*)?https?:\/\/(www\.)?github\.com\/[a-z0-9-]+\/[a-z0-9-._]+\/blob\/([a-z0-9-_.?&=#root/%]*)(\s*\|\|)?/gi;
|
||||||
|
@ -120,6 +121,7 @@ events.add("messageCreate", "codePreviews", async function (msg) {
|
||||||
for (const link of githubLinks) {
|
for (const link of githubLinks) {
|
||||||
const spoiler = REGEX_SPOILER.test(link);
|
const spoiler = REGEX_SPOILER.test(link);
|
||||||
files.push(await processFile(link.replace("/blob/", "/raw/"), link, spoiler));
|
files.push(await processFile(link.replace("/blob/", "/raw/"), link, spoiler));
|
||||||
|
logger.verbose("hf:codePreviews", `Processed GitHub file: ${link}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +129,7 @@ events.add("messageCreate", "codePreviews", async function (msg) {
|
||||||
for (const link of gitlabLinks) {
|
for (const link of gitlabLinks) {
|
||||||
const spoiler = REGEX_SPOILER.test(link);
|
const spoiler = REGEX_SPOILER.test(link);
|
||||||
files.push(await processFile(link.replace("/blob/", "/raw/"), link, spoiler));
|
files.push(await processFile(link.replace("/blob/", "/raw/"), link, spoiler));
|
||||||
|
logger.verbose("hf:codePreviews", `Processed GitLab file: ${link}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +137,7 @@ events.add("messageCreate", "codePreviews", async function (msg) {
|
||||||
for (const link of giteaLinks) {
|
for (const link of giteaLinks) {
|
||||||
const spoiler = REGEX_SPOILER.test(link);
|
const spoiler = REGEX_SPOILER.test(link);
|
||||||
files.push(await processFile(link.replace("/src/", "/raw/"), link, spoiler));
|
files.push(await processFile(link.replace("/src/", "/raw/"), link, spoiler));
|
||||||
|
logger.verbose("hf:codePreviews", `Processed Gitea file: ${link}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,15 +151,16 @@ events.add("messageCreate", "codePreviews", async function (msg) {
|
||||||
if (file == "") continue;
|
if (file == "") continue;
|
||||||
|
|
||||||
if (out.length + file.length > 2000) {
|
if (out.length + file.length > 2000) {
|
||||||
await msg.channel.createMessage({
|
if (out.length > 0)
|
||||||
content: out,
|
await msg.channel.createMessage({
|
||||||
allowedMentions: {
|
content: out,
|
||||||
repliedUser: false,
|
allowedMentions: {
|
||||||
},
|
repliedUser: false,
|
||||||
messageReference: {
|
},
|
||||||
messageID: msg.id,
|
messageReference: {
|
||||||
},
|
messageID: msg.id,
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
out = file;
|
out = file;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -121,20 +121,18 @@ lookupinvite.callback = async function (msg, line) {
|
||||||
|
|
||||||
if (invite.guild.features) {
|
if (invite.guild.features) {
|
||||||
const features = formatGuildFeatures(invite.guild.features);
|
const features = formatGuildFeatures(invite.guild.features);
|
||||||
embed.fields.push(
|
embed.fields.push({
|
||||||
{
|
name: `Features (${features.length})`,
|
||||||
name: `Features (${features.length})`,
|
value: features.length > 0 ? features.slice(0, Math.ceil(features.length / 2)).join("\n") : "None",
|
||||||
value: features.length > 0 ? features.slice(0, Math.ceil(features.length / 2)).join("\n") : "None",
|
inline: true,
|
||||||
|
});
|
||||||
|
if (features.length > 1) {
|
||||||
|
embed.fields.push({
|
||||||
|
name: "\u200b",
|
||||||
|
value: features.slice(Math.ceil(features.length / 2), features.length).join("\n"),
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
});
|
||||||
features.length > 1
|
}
|
||||||
? {
|
|
||||||
name: "\u200b",
|
|
||||||
value: features.slice(Math.ceil(features.length / 2), features.length).join("\n"),
|
|
||||||
inline: true,
|
|
||||||
}
|
|
||||||
: null
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue