UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 1.17 kB
{"version":3,"file":"resolveGuildChannelPredicate.mjs","names":[],"sources":["../../../../../src/lib/utils/resolvers/resolveGuildChannelPredicate.ts"],"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"],"mappings":";;;;AAOA,SAAgB,6BACf,WACA,OACA,WACA,OACmE;AAEnE,QADe,oBAAoB,WAAW,MAAM,CACtC,SAAS,YAAa,UAAU,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,IAAI,MAAM,CAAE"}