File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 1
- import type { ChannelTypes } from '@sapphire/discord.js-utilities' ;
1
+ import { ChannelMentionRegex , ChannelTypes } from '@sapphire/discord.js-utilities' ;
2
2
import { container } from '@sapphire/pieces' ;
3
3
import type { Message , Snowflake } from 'discord.js' ;
4
4
import { Identifiers } from '../errors/Identifiers' ;
5
5
import { err , ok , Result } from '../parsers/Result' ;
6
6
7
7
export function resolveChannel ( parameter : string , message : Message ) : Result < ChannelTypes , Identifiers . ArgumentChannelError > {
8
- const channel = ( message . guild ? message . guild . channels : container . client . channels ) . cache . get ( parameter as Snowflake ) ;
8
+ const channelId = ( ChannelMentionRegex . exec ( parameter ) ?. [ 1 ] ?? parameter ) as Snowflake ;
9
+ const channel = ( message . guild ? message . guild . channels : container . client . channels ) . cache . get ( channelId ) ;
9
10
if ( channel ) return ok ( channel as ChannelTypes ) ;
10
11
return err ( Identifiers . ArgumentChannelError ) ;
11
12
}
You can’t perform that action at this time.
0 commit comments