mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
more fixes
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
e48ca5c075
commit
7c5e6eb91f
18 changed files with 51 additions and 45 deletions
|
@ -1,4 +1,4 @@
|
|||
import { MessageEmbedOptions, MessageMentionTypes, Snowflake, TextChannel } from "discord.js";
|
||||
import { MessageCreateOptions, MessageMentionTypes, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { allowTimeout } from "../../../RegExpRunner";
|
||||
import { ILogTypeData, LogsPluginType, TLogChannel, TLogChannelMap } from "../types";
|
||||
|
@ -141,7 +141,7 @@ export async function log<TLogType extends keyof ILogTypeData>(
|
|||
const buffer = pluginData.state.buffers.get(channelId)!;
|
||||
buffer.push({
|
||||
content: typeof message === "string" ? message : message.content || "",
|
||||
embeds: typeof message === "string" ? [] : ((message.embeds || []) as MessageEmbedOptions[]),
|
||||
embeds: typeof message === "string" ? [] : ((message.embeds || []) as MessageCreateOptions[]),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageEmbedOptions, User } from "discord.js";
|
||||
import { EmbedData, MessageCreateOptions, User } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { emptyEmbedValue, resolveUser, trimLines } from "../../../utils";
|
||||
|
@ -54,7 +54,7 @@ export const CasesModCmd = modActionsCmd({
|
|||
const lastCaseNum = page * casesPerPage;
|
||||
const title = `Most recent cases ${firstCaseNum}-${lastCaseNum} of ${totalCases} by ${modName}`;
|
||||
|
||||
const embed: MessageEmbedOptions = {
|
||||
const embed: EmbedData = {
|
||||
author: {
|
||||
name: title,
|
||||
iconURL: mod instanceof User ? mod.displayAvatarURL() : undefined,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageEmbedOptions, User } from "discord.js";
|
||||
import { EmbedData, User } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { CaseTypes } from "../../../data/CaseTypes";
|
||||
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||
|
@ -116,13 +116,13 @@ export const CasesUserCmd = modActionsCmd({
|
|||
const chunkStart = i * linesPerChunk + 1;
|
||||
const chunkEnd = Math.min((i + 1) * linesPerChunk, lines.length);
|
||||
|
||||
const embed: MessageEmbedOptions = {
|
||||
const embed: EmbedData = {
|
||||
author: {
|
||||
name:
|
||||
lineChunks.length === 1
|
||||
? `Cases for ${userName} (${lines.length} total)`
|
||||
: `Cases ${chunkStart}–${chunkEnd} of ${lines.length} for ${userName}`,
|
||||
icon_url: user instanceof User ? user.displayAvatarURL() : undefined,
|
||||
iconURL: user instanceof User ? user.displayAvatarURL() : undefined,
|
||||
},
|
||||
fields: [
|
||||
...getChunkedEmbedFields(emptyEmbedValue, linesInChunk.join("\n")),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageEmbedOptions } from "discord.js";
|
||||
import { EmbedData } from "discord.js";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { sendErrorMessage } from "../../../pluginUtils";
|
||||
import { isValidEmbed, trimLines } from "../../../utils";
|
||||
|
@ -46,7 +46,7 @@ export const PostEmbedCmd = postCmd({
|
|||
}
|
||||
}
|
||||
|
||||
let embed: MessageEmbedOptions = {};
|
||||
let embed: EmbedData = {};
|
||||
if (args.title) embed.title = args.title;
|
||||
if (color) embed.color = color;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ export function createStarboardEmbedFromMessage(
|
|||
embed.color = color;
|
||||
}
|
||||
|
||||
embed.author.icon_url = msg.author.displayAvatarURL({ dynamic: true });
|
||||
embed.author.iconURL = msg.author.displayAvatarURL();
|
||||
|
||||
// The second condition here checks for messages with only an image link that is then embedded.
|
||||
// The message content in that case is hidden by the Discord client, so we hide it here too.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Message, MessageEmbedOptions, Snowflake, TextChannel } from "discord.js";
|
||||
import { EmbedData, Message, Snowflake, TextChannel } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { StarboardPluginType, TStarboardOpts } from "../types";
|
||||
import { createStarboardEmbedFromMessage } from "./createStarboardEmbedFromMessage";
|
||||
|
@ -16,6 +16,6 @@ export async function saveMessageToStarboard(
|
|||
const embed = createStarboardEmbedFromMessage(msg, Boolean(starboard.copy_full_embed), starboard.color);
|
||||
embed.fields!.push(createStarboardPseudoFooterForMessage(starboard, msg, starboard.star_emoji![0], starCount));
|
||||
|
||||
const starboardMessage = await (channel as TextChannel).send({ embeds: [embed as MessageEmbedOptions] });
|
||||
const starboardMessage = await (channel as TextChannel).send({ embeds: [embed as EmbedData] });
|
||||
await pluginData.state.starboardMessages.createStarboardMessage(channel.id, msg.id, starboardMessage.id);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ export async function getChannelInfoEmbed(
|
|||
|
||||
embed.author = {
|
||||
name: `${channelType}: ${channel.name}`,
|
||||
icon_url: icon,
|
||||
iconURL: icon,
|
||||
};
|
||||
|
||||
let channelName = `#${channel.name}`;
|
||||
|
|
|
@ -36,7 +36,7 @@ export async function getInviteInfoEmbed(
|
|||
};
|
||||
|
||||
if (invite.guild.icon) {
|
||||
embed.author.icon_url = `https://cdn.discordapp.com/icons/${invite.guild.id}/${invite.guild.icon}.png?size=256`;
|
||||
embed.author.iconURL = `https://cdn.discordapp.com/icons/${invite.guild.id}/${invite.guild.icon}.png?size=256`;
|
||||
}
|
||||
|
||||
if (invite.guild.description) {
|
||||
|
|
|
@ -31,7 +31,7 @@ export async function getMessageInfoEmbed(
|
|||
|
||||
embed.author = {
|
||||
name: `Message: ${message.id}`,
|
||||
icon_url: MESSAGE_ICON,
|
||||
iconURL: MESSAGE_ICON,
|
||||
};
|
||||
|
||||
const createdAt = moment.utc(message.createdAt, "x");
|
||||
|
|
|
@ -20,7 +20,7 @@ export async function getRoleInfoEmbed(
|
|||
|
||||
embed.author = {
|
||||
name: `Role: ${role.name}`,
|
||||
icon_url: MENTION_ICON,
|
||||
iconURL: MENTION_ICON,
|
||||
};
|
||||
|
||||
embed.color = role.color;
|
||||
|
|
|
@ -21,7 +21,7 @@ export async function getSnowflakeInfoEmbed(
|
|||
|
||||
embed.author = {
|
||||
name: `Snowflake: ${snowflake}`,
|
||||
icon_url: SNOWFLAKE_ICON,
|
||||
iconURL: SNOWFLAKE_ICON,
|
||||
};
|
||||
|
||||
if (showUnknownWarning) {
|
||||
|
|
|
@ -47,7 +47,7 @@ export async function getUserInfoEmbed(
|
|||
};
|
||||
|
||||
const avatarURL = user.displayAvatarURL();
|
||||
embed.author.icon_url = avatarURL;
|
||||
embed.author.iconURL = avatarURL;
|
||||
|
||||
const createdAt = moment.utc(user.createdAt, "x");
|
||||
const tzCreatedAt = requestMemberId
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import {
|
||||
ActionRowBuilder,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
GuildMember,
|
||||
Message,
|
||||
MessageActionRow,
|
||||
MessageButton,
|
||||
MessageActionRowComponent,
|
||||
MessageActionRowComponentBuilder,
|
||||
MessageComponentInteraction,
|
||||
PermissionsBitField,
|
||||
Snowflake,
|
||||
|
@ -169,23 +172,23 @@ export async function displaySearch(
|
|||
// Set up pagination reactions if needed. The reactions are cleared after a timeout.
|
||||
if (searchResult.totalResults > perPage) {
|
||||
const idMod = `${searchMsg.id}:${moment.utc().valueOf()}`;
|
||||
const buttons: MessageButton[] = [];
|
||||
const buttons: ButtonBuilder[] = [];
|
||||
|
||||
buttons.push(
|
||||
new MessageButton()
|
||||
.setStyle("SECONDARY")
|
||||
new ButtonBuilder()
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
.setEmoji("⬅")
|
||||
.setCustomId(`previousButton:${idMod}`)
|
||||
.setDisabled(currentPage === 1),
|
||||
new MessageButton()
|
||||
.setStyle("SECONDARY")
|
||||
new ButtonBuilder()
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
.setEmoji("➡")
|
||||
.setCustomId(`nextButton:${idMod}`)
|
||||
.setDisabled(currentPage === searchResult.lastPage),
|
||||
new MessageButton().setStyle("SECONDARY").setEmoji("🔄").setCustomId(`reloadButton:${idMod}`),
|
||||
new ButtonBuilder().setStyle(ButtonStyle.Secondary).setEmoji("🔄").setCustomId(`reloadButton:${idMod}`),
|
||||
);
|
||||
|
||||
const row = new MessageActionRow().addComponents(buttons);
|
||||
const row = new ActionRowBuilder<MessageActionRowComponentBuilder>().addComponents(buttons);
|
||||
await searchMsg.edit({ content: result, components: [row] });
|
||||
|
||||
const collector = searchMsg.createMessageComponentCollector({ time: 2 * MINUTES });
|
||||
|
|
|
@ -3,6 +3,9 @@ import {
|
|||
Client,
|
||||
Constants,
|
||||
DiscordAPIError,
|
||||
Embed,
|
||||
EmbedData,
|
||||
EmbedType,
|
||||
Emoji,
|
||||
escapeCodeBlock,
|
||||
Guild,
|
||||
|
@ -16,10 +19,8 @@ import {
|
|||
InviteGuild,
|
||||
LimitedCollection,
|
||||
Message,
|
||||
MessageEmbed,
|
||||
MessageEmbedOptions,
|
||||
MessageCreateOptions,
|
||||
MessageMentionOptions,
|
||||
MessageOptions,
|
||||
PartialChannelData,
|
||||
PartialMessage,
|
||||
Snowflake,
|
||||
|
@ -391,8 +392,7 @@ export const zEmbedInput = z.object({
|
|||
.nullable(),
|
||||
});
|
||||
|
||||
export type EmbedWith<T extends keyof MessageEmbedOptions> = MessageEmbedOptions &
|
||||
Pick<Required<MessageEmbedOptions>, T>;
|
||||
export type EmbedWith<T extends keyof EmbedData> = EmbedData & Pick<Required<EmbedData>, T>;
|
||||
|
||||
export const zStrictMessageContent = z.object({
|
||||
content: z.string().optional(),
|
||||
|
@ -405,7 +405,7 @@ export type ZStrictMessageContent = z.infer<typeof zStrictMessageContent>;
|
|||
export type StrictMessageContent = {
|
||||
content?: string;
|
||||
tts?: boolean;
|
||||
embeds?: MessageEmbedOptions[];
|
||||
embeds?: EmbedData[];
|
||||
};
|
||||
|
||||
export const tStrictMessageContent = t.type({
|
||||
|
@ -647,7 +647,7 @@ interface MatchedURL extends URL {
|
|||
}
|
||||
|
||||
export function getUrlsInString(str: string, onlyUnique = false): MatchedURL[] {
|
||||
let matches = [...str.match(urlRegex)];
|
||||
let matches = [...(str.match(urlRegex) ?? [])];
|
||||
if (onlyUnique) {
|
||||
matches = unique(matches);
|
||||
}
|
||||
|
@ -1405,7 +1405,7 @@ export async function resolveStickerId(bot: Client, id: Snowflake): Promise<Stic
|
|||
export async function confirm(
|
||||
channel: GuildTextBasedChannel,
|
||||
userId: string,
|
||||
content: MessageOptions,
|
||||
content: MessageCreateOptions,
|
||||
): Promise<boolean> {
|
||||
return waitForButtonConfirm(channel, content, { restrictToId: userId });
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ export function messageSummary(msg: SavedMessage) {
|
|||
let result = "```\n" + (msg.data.content ? escapeCodeBlock(msg.data.content) : "<no text content>") + "```";
|
||||
|
||||
// Rich embed
|
||||
const richEmbed = (msg.data.embeds || []).find((e) => (e as MessageEmbed).type === "rich");
|
||||
const richEmbed = (msg.data.embeds || []).find((e) => (e as EmbedData).type === EmbedType.Rich);
|
||||
if (richEmbed) result += "Embed:```" + escapeCodeBlock(JSON.stringify(richEmbed)) + "```";
|
||||
|
||||
// Attachments
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageEmbedOptions } from "discord.js";
|
||||
import { EmbedData } from "discord.js";
|
||||
|
||||
function sumStringLengthsRecursively(obj: any): number {
|
||||
if (obj == null) return 0;
|
||||
|
@ -12,6 +12,6 @@ function sumStringLengthsRecursively(obj: any): number {
|
|||
return 0;
|
||||
}
|
||||
|
||||
export function calculateEmbedSize(embed: MessageEmbedOptions): number {
|
||||
export function calculateEmbedSize(embed: EmbedData): number {
|
||||
return sumStringLengthsRecursively(embed);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import {
|
||||
Client,
|
||||
GuildTextBasedChannel,
|
||||
Message,
|
||||
MessageCreateOptions,
|
||||
MessageEditOptions,
|
||||
MessageOptions,
|
||||
MessageReaction,
|
||||
PartialMessageReaction,
|
||||
PartialUser,
|
||||
TextBasedChannel,
|
||||
TextChannel,
|
||||
User,
|
||||
} from "discord.js";
|
||||
|
@ -13,7 +15,7 @@ import { Awaitable } from "knub/dist/utils";
|
|||
import { MINUTES, noop } from "../utils";
|
||||
import Timeout = NodeJS.Timeout;
|
||||
|
||||
export type LoadPageFn = (page: number) => Awaitable<MessageOptions & MessageEditOptions>;
|
||||
export type LoadPageFn = (page: number) => Awaitable<MessageCreateOptions & MessageEditOptions>;
|
||||
|
||||
export interface PaginateMessageOpts {
|
||||
timeout: number;
|
||||
|
@ -27,7 +29,7 @@ const defaultOpts: PaginateMessageOpts = {
|
|||
|
||||
export async function createPaginatedMessage(
|
||||
client: Client,
|
||||
channel: TextChannel | User,
|
||||
channel: TextBasedChannel | User,
|
||||
totalPages: number,
|
||||
loadPageFn: LoadPageFn,
|
||||
opts: Partial<PaginateMessageOpts> = {},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { MessageOptions } from "discord.js";
|
||||
import { MessageOptions } from "child_process";
|
||||
import { MessageCreateOptions, MessagePayload } from "discord.js";
|
||||
|
||||
function embedHasContent(embed: any) {
|
||||
for (const [key, value] of Object.entries(embed)) {
|
||||
|
@ -18,7 +19,7 @@ function embedHasContent(embed: any) {
|
|||
return false;
|
||||
}
|
||||
|
||||
export function messageHasContent(content: string | MessageOptions): boolean {
|
||||
export function messageHasContent(content: string | MessageCreateOptions): boolean {
|
||||
if (typeof content === "string") {
|
||||
return content.trim() !== "";
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { MessageOptions } from "discord.js";
|
||||
import { MessageCreateOptions } from "discord.js";
|
||||
import { messageHasContent } from "./messageHasContent";
|
||||
|
||||
export function messageIsEmpty(content: string | MessageOptions): boolean {
|
||||
export function messageIsEmpty(content: string | MessageCreateOptions): boolean {
|
||||
return !messageHasContent(content);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue