mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
fix: InternalPoster webhookables
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
fda9a35f29
commit
aad4ad82a5
1 changed files with 11 additions and 4 deletions
|
@ -1,13 +1,20 @@
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { InternalPosterPluginType } from "../types";
|
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";
|
import { isDiscordAPIError } from "../../../utils";
|
||||||
|
|
||||||
type WebhookInfo = [id: string, token: string];
|
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;
|
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);
|
const member = pluginData.client.user && pluginData.guild.members.cache.get(pluginData.client.user.id);
|
||||||
if (!member || member.permissions.has(PermissionsBitField.Flags.ManageWebhooks)) {
|
if (!member || member.permissions.has(PermissionsBitField.Flags.ManageWebhooks)) {
|
||||||
try {
|
try {
|
||||||
const webhook = await channel.createWebhook(`Zephook ${channel.id}`);
|
const webhook = await channel.createWebhook({ name: `Zephook ${channel.id}` });
|
||||||
await pluginData.state.webhooks.create({
|
await pluginData.state.webhooks.create({
|
||||||
id: webhook.id,
|
id: webhook.id,
|
||||||
guild_id: pluginData.guild.id,
|
guild_id: pluginData.guild.id,
|
||||||
|
|
Loading…
Add table
Reference in a new issue