diff --git a/backend/src/plugins/InternalPoster/functions/getOrCreateWebhookForChannel.ts b/backend/src/plugins/InternalPoster/functions/getOrCreateWebhookForChannel.ts index d0652f3b..e95a7913 100644 --- a/backend/src/plugins/InternalPoster/functions/getOrCreateWebhookForChannel.ts +++ b/backend/src/plugins/InternalPoster/functions/getOrCreateWebhookForChannel.ts @@ -1,13 +1,20 @@ import { GuildPluginData } from "knub"; import { InternalPosterPluginType } from "../types"; -import { AnyChannel, GuildChannel, MessageManager, NewsChannel, PermissionsBitField, TextChannel } from "discord.js"; +import { + GuildBasedChannel, + GuildChannel, + MessageManager, + NewsChannel, + PermissionsBitField, + TextChannel, +} from "discord.js"; import { isDiscordAPIError } from "../../../utils"; type WebhookInfo = [id: string, token: string]; -export type WebhookableChannel = Extract any }>; +export type WebhookableChannel = Extract any }>; -export function channelIsWebhookable(channel: AnyChannel): channel is WebhookableChannel { +export function channelIsWebhookable(channel: GuildBasedChannel): channel is WebhookableChannel { return "createWebhook" in channel; } @@ -29,7 +36,7 @@ export async function getOrCreateWebhookForChannel( const member = pluginData.client.user && pluginData.guild.members.cache.get(pluginData.client.user.id); if (!member || member.permissions.has(PermissionsBitField.Flags.ManageWebhooks)) { try { - const webhook = await channel.createWebhook(`Zephook ${channel.id}`); + const webhook = await channel.createWebhook({ name: `Zephook ${channel.id}` }); await pluginData.state.webhooks.create({ id: webhook.id, guild_id: pluginData.guild.id,