@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
16 lines (14 loc) • 697 B
JavaScript
import { Identifiers } from "../errors/Identifiers.mjs";
import { container } from "@sapphire/pieces";
import { Result } from "@sapphire/result";
import { ChannelMentionRegex } from "@sapphire/discord.js-utilities";
//#region src/lib/resolvers/channel.ts
function resolveChannel(parameter, messageOrInteraction) {
const channelId = ChannelMentionRegex.exec(parameter)?.[1] ?? parameter;
const channel = (messageOrInteraction.guild ? messageOrInteraction.guild.channels : container.client.channels).cache.get(channelId);
if (channel) return Result.ok(channel);
return Result.err(Identifiers.ArgumentChannelError);
}
//#endregion
export { resolveChannel };
//# sourceMappingURL=channel.mjs.map