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

fix: InternalPoster webhookables

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
metal 2023-03-11 14:33:05 +00:00 committed by GitHub
parent fda9a35f29
commit aad4ad82a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<AnyChannel, { createWebhook: (...args: any[]) => any }>;
export type WebhookableChannel = Extract<GuildBasedChannel, { createWebhook: (...args: any[]) => 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,