Here is my code, everything up to clearChat functon works. It throws no error but it doesn't delete the messages.
const bot = new Discord.Client();
bot.on('message', msg => {
const args = msg.content.substring(config.prefix.length).split(' ');
switch (args[0]) {
case 'clear':
if(isNaN(args[1])) return msg.reply('Define the amount of messages you want to clear!');
else if(args[1] > 101 ) return msg.reply('Cannot clear more than 100 messages!');
else if(args[1] < 1)) return msg.reply('Must clear at least 1 message!');
else {
clearChat = async(msg, args) => {
let deleteAmount = +args[1] + 1;
messages = await msg.channel.messages.fetch({ limit: deleteAmount }).then(async(messages) => {
await msg.channel.bulkDelete(messages);
});
};
};
break;
};
});