UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 1.34 kB
{"version":3,"sources":["../../../../../src/lib/utils/resolvers/resolveGuildChannelPredicate.ts"],"names":[],"mappings":";;;;AAOO,SAAS,4BACf,CAAA,SAAA,EACA,KACA,EAAA,SAAA,EACA,KACmE,EAAA;AACnE,EAAM,MAAA,MAAA,GAAS,mBAAoB,CAAA,SAAA,EAAW,KAAK,CAAA;AACnD,EAAA,OAAO,MAAO,CAAA,OAAA,CAAQ,CAAC,OAAA,KAAa,UAAU,OAAO,CAAA,GAAI,MAAO,CAAA,EAAA,CAAG,OAAO,CAAA,GAAI,MAAO,CAAA,GAAA,CAAI,KAAK,CAAE,CAAA;AACjG;AARgB,MAAA,CAAA,4BAAA,EAAA,8BAAA,CAAA","file":"resolveGuildChannelPredicate.mjs","sourcesContent":["import type { ChannelTypes, GuildBasedChannelTypes } from '@sapphire/discord.js-utilities';\nimport { Result } from '@sapphire/result';\nimport type { Nullish } from '@sapphire/utilities';\nimport type { Guild } from 'discord.js';\nimport type { Identifiers } from '../../errors/Identifiers';\nimport { resolveGuildChannel } from '../../resolvers/guildChannel';\n\nexport function resolveGuildChannelPredicate<TChannel extends GuildBasedChannelTypes, TError extends Identifiers>(\n\tparameter: string,\n\tguild: Guild,\n\tpredicate: (channel: ChannelTypes | Nullish) => channel is TChannel,\n\terror: TError\n): Result<TChannel, TError | Identifiers.ArgumentGuildChannelError> {\n\tconst result = resolveGuildChannel(parameter, guild);\n\treturn result.mapInto((channel) => (predicate(channel) ? Result.ok(channel) : Result.err(error)));\n}\n"]}