A simple Discord bot that scans messages for supported links (like Pinterest or Pixiv), suppresses Discord's native embeds, and sends a custom embed preview instead. This guide covers how to install and run the bot, with optional instructions for using PM2 for process management.
Discord_yZmg59v2dr.mp4
- Node.js v16.9.0 or higher (required for Discord.js v14)
- A Discord bot token (obtained from the Discord Developer Portal)
- Optional: PM2 for process management
- A code editor (e.g., VS Code)
- A terminal or command-line interface
- Git (for cloning the repository)
-
Clone the repository
Clone the Embed Bot repository to your local machine and navigate to the project directory:
git clone https://github.com/0xGoldstar/Discord-embed-fixer.git cd embed-bot -
Install dependencies
Install the required Node.js packages, including Discord.js, using npm:
npm install
This will install
discord.jsand any other dependencies listed inpackage.json. -
Configure the bot
Create a
.envfile in the project root to store your Discord bot token:touch .env
Add the following line to the
.envfile, replacingYOUR_BOT_TOKENwith your actual bot token from the Discord Developer Portal:DISCORD_TOKEN=YOUR_BOT_TOKENEnsure the
.envfile is listed in.gitignoreto prevent exposing your token. -
Invite the bot to your server
- Go to the Discord Developer Portal.
- Select your bot application, navigate to the "OAuth2" tab, and use the OAuth2 URL Generator.
- Select the
botscope and the necessary permissions (e.g.,Send Messages,Embed Links,Read Messages/View Channels). - Copy the generated URL, open it in a browser, and invite the bot to your server.
-
Start the bot
In the project directory, run the main bot script (e.g.,
index.js):node index.js
The bot should log in to Discord and start processing messages. You’ll see a message like
Logged in as Embed Bot#1234in the terminal if successful. -
Stop the bot
To stop the bot, press
Ctrl + Cin the terminal.
PM2 is a process manager that keeps your bot running in the background, restarts it on crashes, and provides monitoring tools.
-
Install PM2 globally
If PM2 is not already installed, install it using npm:
npm install -g pm2
-
Start the bot with PM2
In the project directory, start the bot using PM2:
pm2 start index.js --name "embed-bot"- The
--name "embed-bot"option names the process for easier management. - PM2 will keep the bot running in the background and automatically restart it if it crashes.
- The
-
Monitor the bot
Check the status of your bot:
pm2 status
View logs in real-time:
pm2 logs embed-bot
-
Stop or restart the bot
To stop the bot:
pm2 stop embed-bot
To restart the bot (e.g., after making code changes):
pm2 restart embed-bot
-
Save PM2 configuration
To ensure PM2 restarts the bot automatically on system reboot:
pm2 save
Generate a startup script for PM2:
pm2 startup
Follow the output instructions to configure PM2 to run on system startup.