Rework bot function #13

Merged
AstroGD merged 15 commits from feature/12-show-warning-if-logchannel-is-unreachable into dev 2022-11-29 03:07:01 +01:00
Showing only changes of commit 0d69cf3e7b - Show all commits

View File

@ -1,4 +1,4 @@
import { GuildBasedChannel } from "discord.js";
import { GuildBasedChannel, GuildTextBasedChannel, PermissionsBitField } from "discord.js";
import client from "../client";
export async function getGuildChannel(guildID: string, channelID: string): Promise<GuildBasedChannel | null> {
@ -8,3 +8,14 @@ export async function getGuildChannel(guildID: string, channelID: string): Promi
const channel = await guild.channels.fetch(channelID);
return channel;
}
export async function getChannelPermission(channel: GuildTextBasedChannel): Promise<Readonly<PermissionsBitField> | null> {
try {
const guildMember = await channel.guild.members.fetch(client.user!.id);
if (!guildMember) return null;
return channel.permissionsFor(guildMember);
} catch (error) {
return null;
}
}