Skip to content

Commit 014f3d0

Browse files
Deal with embeds that are too large
1 parent e20e121 commit 014f3d0

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

package-lock.json

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/docs/djs.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Command } from "../../interfaces";
22
import { SlashCommandBuilder } from "@discordjs/builders";
33
import Doc, { sources } from "discord.js-docs";
4+
import { checkEmbedLimits } from "../../utils/embedUtils";
45

56
const supportedBranches = Object.keys(sources).map((branch) => [capitalize(branch), branch] as [string, string]);
67

@@ -23,6 +24,7 @@ const command: Command = {
2324
),
2425
async execute(interaction, context) {
2526
const query = interaction.options.getString("query");
27+
// The Default source should be stable
2628
const source: keyof typeof sources =
2729
(interaction.options.getString("source") as keyof typeof sources) || "stable";
2830

@@ -40,7 +42,11 @@ const command: Command = {
4042
}
4143

4244
const timeStampDate = new Date(resultEmbed.timestamp);
43-
const embedObj = { ...resultEmbed, timestamp: timeStampDate };
45+
let embedObj = {...resultEmbed, timestamp: timeStampDate};
46+
if(!checkEmbedLimits([resultEmbed])) {
47+
// The final fields should be the View Source button
48+
embedObj.fields = [embedObj.fields?.at(-1)]
49+
}
4450
interaction.reply({ embeds: [embedObj] }).catch(console.error);
4551
return;
4652
},

0 commit comments

Comments
 (0)