@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
1 lines • 1.42 kB
Source Map (JSON)
{"version":3,"sources":["../../../../src/lib/resolvers/channel.ts"],"names":[],"mappings":";;;;;;AAMO,SAAS,cAAA,CACf,WACA,oBACyD,EAAA;AACzD,EAAA,MAAM,YAAa,mBAAoB,CAAA,IAAA,CAAK,SAAS,CAAA,GAAI,CAAC,CAAK,IAAA,SAAA;AAC/D,EAAM,MAAA,OAAA,GAAA,CAAW,oBAAqB,CAAA,KAAA,GAAQ,oBAAqB,CAAA,KAAA,CAAM,QAAW,GAAA,SAAA,CAAU,MAAO,CAAA,QAAA,EAAU,KAAM,CAAA,GAAA,CAAI,SAAS,CAAA;AAElI,EAAA,IAAI,OAAS,EAAA;AACZ,IAAO,OAAA,MAAA,CAAO,GAAG,OAAuB,CAAA;AAAA;AAGzC,EAAO,OAAA,MAAA,CAAO,GAAI,CAAA,WAAA,CAAY,oBAAoB,CAAA;AACnD;AAZgB,MAAA,CAAA,cAAA,EAAA,gBAAA,CAAA","file":"channel.mjs","sourcesContent":["import { ChannelMentionRegex, type ChannelTypes } from '@sapphire/discord.js-utilities';\nimport { container } from '@sapphire/pieces';\nimport { Result } from '@sapphire/result';\nimport type { CommandInteraction, Message, Snowflake } from 'discord.js';\nimport { Identifiers } from '../errors/Identifiers';\n\nexport function resolveChannel(\n\tparameter: string,\n\tmessageOrInteraction: Message | CommandInteraction\n): Result<ChannelTypes, Identifiers.ArgumentChannelError> {\n\tconst channelId = (ChannelMentionRegex.exec(parameter)?.[1] ?? parameter) as Snowflake;\n\tconst channel = (messageOrInteraction.guild ? messageOrInteraction.guild.channels : container.client.channels).cache.get(channelId);\n\n\tif (channel) {\n\t\treturn Result.ok(channel as ChannelTypes);\n\t}\n\n\treturn Result.err(Identifiers.ArgumentChannelError);\n}\n"]}