Rework bot function #13
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user