3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 14:11:50 +00:00

Fix being unable to !post to announcement channels or threads

This commit is contained in:
Dragory 2021-08-21 00:59:51 +03:00
parent ca9ea60082
commit 05df81ddca
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
5 changed files with 15 additions and 11 deletions

View file

@ -3,12 +3,12 @@ import { LogsPluginType } from "../types";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { log } from "../util/log"; import { log } from "../util/log";
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter"; import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter";
import { BaseGuildTextChannel, User } from "discord.js"; import { BaseGuildTextChannel, ThreadChannel, User } from "discord.js";
import { channelToTemplateSafeChannel, userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { channelToTemplateSafeChannel, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
interface LogRepeatedMessageData { interface LogRepeatedMessageData {
author: User; author: User;
channel: BaseGuildTextChannel; channel: BaseGuildTextChannel | ThreadChannel;
datetime: string; datetime: string;
date: string; date: string;
time: string; time: string;

View file

@ -3,12 +3,12 @@ import { LogsPluginType } from "../types";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { log } from "../util/log"; import { log } from "../util/log";
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter"; import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter";
import { BaseGuildTextChannel, User } from "discord.js"; import { BaseGuildTextChannel, ThreadChannel, User } from "discord.js";
import { channelToTemplateSafeChannel, userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { channelToTemplateSafeChannel, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
interface LogScheduledMessageData { interface LogScheduledMessageData {
author: User; author: User;
channel: BaseGuildTextChannel; channel: BaseGuildTextChannel | ThreadChannel;
datetime: string; datetime: string;
date: string; date: string;
time: string; time: string;

View file

@ -3,12 +3,12 @@ import { LogsPluginType } from "../types";
import { LogType } from "../../../data/LogType"; import { LogType } from "../../../data/LogType";
import { log } from "../util/log"; import { log } from "../util/log";
import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter"; import { createTypedTemplateSafeValueContainer } from "../../../templateFormatter";
import { BaseGuildTextChannel, User } from "discord.js"; import { BaseGuildTextChannel, ThreadChannel, User } from "discord.js";
import { channelToTemplateSafeChannel, userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { channelToTemplateSafeChannel, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
interface LogScheduledRepeatedMessageData { interface LogScheduledRepeatedMessageData {
author: User; author: User;
channel: BaseGuildTextChannel; channel: BaseGuildTextChannel | ThreadChannel;
datetime: string; datetime: string;
date: string; date: string;
time: string; time: string;

View file

@ -1,4 +1,4 @@
import { Channel, Message, TextChannel } from "discord.js"; import { Channel, Message, NewsChannel, TextChannel, ThreadChannel } from "discord.js";
import humanizeDuration from "humanize-duration"; import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import moment from "moment-timezone"; import moment from "moment-timezone";
@ -29,8 +29,12 @@ export async function actualPostCmd(
"repeat-times"?: number; "repeat-times"?: number;
} = {}, } = {},
) { ) {
if (!(targetChannel instanceof TextChannel)) { if (
msg.channel.send(errorMessage("Channel is not a text channel")); !(targetChannel instanceof TextChannel) &&
!(targetChannel instanceof NewsChannel) &&
!(targetChannel instanceof ThreadChannel)
) {
msg.channel.send(errorMessage("Specified channel is not a text channel, announcement channel, or thread"));
return; return;
} }

View file

@ -1,4 +1,4 @@
import { Message, MessageAttachment, MessageOptions, TextChannel } from "discord.js"; import { Message, MessageAttachment, MessageOptions, NewsChannel, TextChannel, ThreadChannel } from "discord.js";
import fs from "fs"; import fs from "fs";
import { GuildPluginData } from "knub"; import { GuildPluginData } from "knub";
import { downloadFile } from "../../../utils"; import { downloadFile } from "../../../utils";
@ -9,7 +9,7 @@ const fsp = fs.promises;
export async function postMessage( export async function postMessage(
pluginData: GuildPluginData<PostPluginType>, pluginData: GuildPluginData<PostPluginType>,
channel: TextChannel, channel: TextChannel | NewsChannel | ThreadChannel,
content: MessageOptions, content: MessageOptions,
attachments: MessageAttachment[] = [], attachments: MessageAttachment[] = [],
enableMentions: boolean = false, enableMentions: boolean = false,