transform to array before filtering

This commit is contained in:
almeidx 2021-08-04 21:02:12 +01:00
parent 3537305c59
commit a11c39cd0a
No known key found for this signature in database
GPG key ID: 8558FBFF849BD664

View file

@ -46,11 +46,9 @@ export const VcmoveCmd = utilityCmd({
channel = potentialChannel; channel = potentialChannel;
} else { } else {
// Search string -> find closest matching voice channel name // Search string -> find closest matching voice channel name
const voiceChannels = [ const voiceChannels = [...pluginData.guild.channels.cache.values()].filter(
...pluginData.guild.channels.cache (c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE,
.filter((c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE) );
.values(),
];
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name); const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name);
if (!closestMatch) { if (!closestMatch) {
sendErrorMessage(pluginData, msg.channel, "No matching voice channels"); sendErrorMessage(pluginData, msg.channel, "No matching voice channels");
@ -127,11 +125,9 @@ export const VcmoveAllCmd = utilityCmd({
channel = potentialChannel; channel = potentialChannel;
} else { } else {
// Search string -> find closest matching voice channel name // Search string -> find closest matching voice channel name
const voiceChannels = [ const voiceChannels = [...pluginData.guild.channels.cache.values()].filter(
...pluginData.guild.channels.cache (c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE,
.filter((c): c is VoiceChannel => c.type === ChannelTypeStrings.VOICE) );
.values(),
];
const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name); const closestMatch = simpleClosestStringMatch(args.channel, voiceChannels, ch => ch.name);
if (!closestMatch) { if (!closestMatch) {
sendErrorMessage(pluginData, msg.channel, "No matching voice channels"); sendErrorMessage(pluginData, msg.channel, "No matching voice channels");