@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
1 lines • 1.38 kB
Source Map (JSON)
{"version":3,"sources":["../../../../../src/lib/utils/resolvers/resolveGuildChannelPredicate.ts"],"names":["result","resolveGuildChannel","Result"],"mappings":";;;;;;;AAOO,SAAS,4BACf,CAAA,SAAA,EACA,KACA,EAAA,SAAA,EACA,KACmE,EAAA;AACnE,EAAM,MAAAA,QAAA,GAASC,oCAAoB,CAAA,SAAA,EAAW,KAAK,CAAA;AACnD,EAAA,OAAOD,QAAO,CAAA,OAAA,CAAQ,CAAC,OAAA,KAAa,UAAU,OAAO,CAAA,GAAIE,aAAO,CAAA,EAAA,CAAG,OAAO,CAAA,GAAIA,aAAO,CAAA,GAAA,CAAI,KAAK,CAAE,CAAA;AACjG;AARgB,MAAA,CAAA,4BAAA,EAAA,8BAAA,CAAA","file":"resolveGuildChannelPredicate.cjs","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"]}