# Automod

Many automod bots will ignore messages sent via WidgetBot, which can be annoying to admins. A solution is using Pylon (opens new window) and code it yourself. In this guide, we'll make a simple check to delete invite links.

First, you'll need to add the Pylon bot to your server (opens new window).
Then, click your server in the list and click "Open Code Editor". Delete the example code in the editor, so it's blank.

This code will delete all messages sent invite links detected with a regex (opens new window):

const inviteRegex = /(discord\.(gg|io|me|li)|discord(app)?\.com\/invite)(\/.+)/i;

discord.on('MESSAGE_CREATE', async (msg) => {
  if (inviteRegex.test(msg.content)) await msg.delete();

Paste that in and save. Pylon should now instantly delete messages containing an invite link.

Need help with Pylon?

Go to the Pylon Discord server (opens new window) to get help with using Pylon.