Add channel permission getter
This commit is contained in:
parent
730151e34b
commit
0d69cf3e7b
@ -1,4 +1,4 @@
|
|||||||
import { GuildBasedChannel } from "discord.js";
|
import { GuildBasedChannel, GuildTextBasedChannel, PermissionsBitField } from "discord.js";
|
||||||
import client from "../client";
|
import client from "../client";
|
||||||
|
|
||||||
export async function getGuildChannel(guildID: string, channelID: string): Promise<GuildBasedChannel | null> {
|
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);
|
const channel = await guild.channels.fetch(channelID);
|
||||||
return channel;
|
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