minetest.register_on_chat_message(function(name, message)
if message:sub(1, 1) ~= "/" and cloaked_players[name] then
minetest.chat_send_player(name, "You cannot use chat while cloaked." ..
" Please use /uncloak if you want to use chat.")
return true
end
end)
Chat commands are chat messages too. See https://rubenwardy.com/minetest_modding_book/en/players/chat.html#intercepting-messages