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

more fixes

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
metal 2023-03-11 12:12:48 +00:00 committed by GitHub
parent 343a91e3c3
commit c33a216857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 81 additions and 58 deletions

View file

@ -38,7 +38,7 @@ export const AlertAction = automodAction({
const channel = pluginData.guild.channels.cache.get(actionConfig.channel as Snowflake);
const logs = pluginData.getPlugin(LogsPlugin);
if (channel?.isText()) {
if (channel?.isTextBased()) {
const text = actionConfig.text;
const theMessageLink =
contexts[0].message && messageLink(pluginData.guild.id, contexts[0].message.channel_id, contexts[0].message.id);

View file

@ -36,7 +36,7 @@ export const ReplyAction = automodAction({
.filter((c) => c.message?.channel_id)
.filter((c) => {
const channel = pluginData.guild.channels.cache.get(c.message!.channel_id as Snowflake);
return channel?.isText();
return channel?.isTextBased();
});
const contextsByChannelId = contextsWithTextChannels.reduce((map: Map<string, AutomodContext[]>, context) => {

View file

@ -32,7 +32,7 @@ export const StartThreadAction = automodAction({
const threads = contexts.filter((c) => {
if (!c.message || !c.user) return false;
const channel = pluginData.guild.channels.cache.get(c.message.channel_id);
if (channel?.type !== ChannelTypeStrings.TEXT || !channel.isText()) return false; // for some reason the typing here for channel.type defaults to ThreadChannelTypes (?)
if (channel?.type !== ChannelTypeStrings.TEXT || !channel.isTextBased()) return false; // for some reason the typing here for channel.type defaults to ThreadChannelTypes (?)
// check against max threads per channel
if (actionConfig.limit_per_channel && actionConfig.limit_per_channel > 0) {
const threadCount = channel.threads.cache.filter(

View file

@ -19,7 +19,7 @@ export function resolveActionContactMethods(
}
const channel = pluginData.guild.channels.cache.get(actionConfig.notifyChannel as Snowflake);
if (!channel?.isText()) {
if (!channel?.isTextBased()) {
throw new RecoverablePluginError(ERRORS.INVALID_USER_NOTIFICATION_CHANNEL);
}

View file

@ -68,7 +68,7 @@ export const ViewCounterCmd = guildPluginMessageCommand<CountersPluginType>()({
}
const potentialChannel = pluginData.guild.channels.resolve(reply.content as Snowflake);
if (!potentialChannel?.isText()) {
if (!potentialChannel?.isTextBased()) {
sendErrorMessage(pluginData, message.channel, "Channel is not a text channel, cancelling");
return;
}

View file

@ -88,7 +88,7 @@ export async function log<TLogType extends keyof ILogTypeData>(
logChannelLoop: for (const [channelId, opts] of Object.entries(logChannels)) {
const channel = pluginData.guild.channels.cache.get(channelId as Snowflake);
if (!channel?.isText()) continue;
if (!channel?.isTextBased()) continue;
if (pluginData.state.channelCooldowns.isOnCooldown(channelId)) continue;
if (opts.include?.length && !opts.include.includes(typeStr)) continue;
if (opts.exclude && opts.exclude.includes(typeStr)) continue;

View file

@ -186,7 +186,7 @@ export async function muteUser(
const channel = config.message_channel
? pluginData.guild.channels.cache.get(config.message_channel as Snowflake)
: null;
if (useChannel && channel?.isText()) {
if (useChannel && channel?.isTextBased()) {
contactMethods.push({ type: "channel", channel });
}
}

View file

@ -30,7 +30,7 @@ export async function actualPostCmd(
"repeat-times"?: number;
} = {},
) {
if (!targetChannel.isText()) {
if (!targetChannel.isTextBased()) {
msg.channel.send(errorMessage("Specified channel is not a text-based channel"));
return;
}

View file

@ -45,7 +45,7 @@ export async function postScheduledPost(pluginData: GuildPluginData<PostPluginTy
// Post the message
const channel = pluginData.guild.channels.cache.get(post.channel_id as Snowflake);
if (channel?.isText() || channel?.isThread()) {
if (channel?.isTextBased() || channel?.isThread()) {
const [username, discriminator] = post.author_name.split("#");
const author: User = (await pluginData.client.users.fetch(post.author_id as Snowflake)) || {
id: post.author_id,

View file

@ -9,7 +9,7 @@ import humanizeDuration from "humanize-duration";
export async function postReminder(pluginData: GuildPluginData<RemindersPluginType>, reminder: Reminder) {
const channel = pluginData.guild.channels.cache.get(reminder.channel_id as Snowflake);
if (channel && (channel.isText() || channel.isThread())) {
if (channel && (channel.isTextBased() || channel.isThread())) {
try {
// Only show created at date if one exists
if (moment.utc(reminder.created_at).isValid()) {

View file

@ -19,7 +19,7 @@ export async function applyRoleButtons(
// Remove existing role buttons, if any
if (existingSavedButtons?.channel_id) {
const existingChannel = await pluginData.guild.channels.fetch(configItem.message.channel_id).catch(() => null);
const existingMessage = await (existingChannel?.isText() &&
const existingMessage = await (existingChannel?.isTextBased() &&
existingChannel.messages.fetch(existingSavedButtons.message_id).catch(() => null));
if (existingMessage && existingMessage.components.length) {
await existingMessage.edit({
@ -32,7 +32,7 @@ export async function applyRoleButtons(
if ("message_id" in configItem.message) {
// channel id + message id: apply role buttons to existing message
const channel = await pluginData.guild.channels.fetch(configItem.message.channel_id).catch(() => null);
const messageCandidate = await (channel?.isText() &&
const messageCandidate = await (channel?.isTextBased() &&
channel.messages.fetch(configItem.message.message_id).catch(() => null));
if (!messageCandidate) {
pluginData.getPlugin(LogsPlugin).logBotAlert({
@ -55,10 +55,10 @@ export async function applyRoleButtons(
}
const channel = await pluginData.guild.channels.fetch(configItem.message.channel_id).catch(() => null);
if (channel && (!channel.isText || typeof channel.isText !== "function")) {
if (channel && (!channel.isTextBased || typeof channel.isTextBased !== "function")) {
console.log("wtf", pluginData.guild?.id, configItem.message.channel_id);
}
if (!channel || !channel?.isText?.()) {
if (!channel || !channel?.isTextBased()) {
pluginData.getPlugin(LogsPlugin).logBotAlert({
body: `Text channel not found for role_buttons/${configItem.name}`,
});

View file

@ -1,3 +1,4 @@
import { ChannelType } from "discord.js";
import { GuildPluginData } from "knub";
import { StarboardMessage } from "../../../data/entities/StarboardMessage";
import { noop } from "../../../utils";
@ -12,7 +13,7 @@ export async function removeMessageFromStarboard(
// this code is now Almeida-certified and no longer ugly :ok_hand: :cake:
const channel = pluginData.client.channels.cache.find((c) => c.id === msg.starboard_channel_id);
if (!channel?.isText()) return;
if (channel?.type !== ChannelType.GuildText) return;
const message = await channel.messages.fetch(msg.starboard_message_id).catch(noop);
if (!message?.deletable) return;
await message.delete().catch(noop);

View file

@ -81,7 +81,7 @@ export async function cleanCmd(pluginData: GuildPluginData<UtilityPluginType>, a
}
const targetChannel = args.channel ? pluginData.guild.channels.cache.get(args.channel as Snowflake) : msg.channel;
if (!targetChannel?.isText()) {
if (!targetChannel?.isTextBased()) {
sendErrorMessage(pluginData, msg.channel, `Invalid channel specified`);
return;
}

View file

@ -1,4 +1,4 @@
import { MessageEmbedOptions, Role } from "discord.js";
import { MessageEmbedOptions } from "discord.js";
import humanizeDuration from "humanize-duration";
import { GuildPluginData } from "knub";
import moment from "moment-timezone";