That menas that msg.channel.query is undefined. on line 14.
console.log out the msg passed to the function and debug.
This would seem to be some sort of library and is parsing out what TMI sends into an object and the object doesn’t contain what you expect it to.