For days i cant figure out how to get the for loop to iterate over all items and then run the conditional. So I want it to iterate overall the channels and then check if its true. It will run the conditionals on each item as they pass. When the conditional is true it. Ive tried mapping, probably incorrectly, and even tried to turn it into a JSON. I even started messiong with Message collections.
It works in Javascript so not sure what typescript is doing. Any help is much appreciated.
export = {
name: 'addfav',
aliases: ['Addfav'],
type: CommandTypes.PrefixCommand,
channelWhitelist: ['1147233774938107966'],
ownerOnly: true,
async execute(message: Message): Promise<void> {
if (!message.mentions.channels.map((m) => m).length) {
await message.reply('Did you forget to add the channel?');
} else {
let getChannel = await message.content.replace(/D/g, '');
let isAdded = await checkfav(message.author.id);
for (var i = 0; i < isAdded.length; i++) {
if (isAdded[i].channel === getChannel) {
await message.reply('You already have a channel');
break;
} else {
await addfav(getChannel);
await message.reply('Channel added');
}
}
}
},
};