Can I change the contents of the npm modules?

I want to change one module(discord-anti-spam) but don’t know how to do it

The contents of that module are hosted in this Github repository. You can’t change the code in node-modules if you’ve installed it through package.json, but you could make a copy of the files you need (probably anti_spam.js) and make changes there. Then you’d reference that file in your project instead of the one from node_modules. (You’ll probably want to remove it from package.json entirely so it doesn’t conflict.)

If you do go this route, make sure to also include the License file from that Github repository in your project, too. The original creator has said you’re free to reuse and modify the files, as long as you include the license that gives the original creator credit for their work.