Before you start

  • Web hosting with us with Python or Node.js. You pick it when you order.
  • A Discord account and a server where you may add bots.
  • The bot's code: in Python for example with the discord.py library, in Node.js with discord.js.

1. Create the bot on Discord

  1. Open the Discord Developer Portal at discord.com/developers/applications, click New Application, enter a name and confirm.
  2. On the left open the Bot page, click Reset Token and copy the token. It is shown only once.
  3. If the bot reads the text of messages (for example commands that start with an exclamation mark), turn on Message Content Intent on the same page. A bot with only slash commands doesn't need it.
  4. On the Installation page, in Default Install Settings, add the scopes bot and applications.commands under Guild Install and pick the bot's permissions. Open the link from Install Link (Discord Provided Link) in your browser and add the bot to your server.

2. Get the code ready

  1. Python: the main file is bot.py, and you list the libraries in requirements.txt, one per line, for example discord.py and python-dotenv.
  2. In bot.py load the token from the .env file: at the top import os, from dotenv import load_dotenv and load_dotenv(). Then start the bot, for example with client.run(os.getenv("DISCORD_TOKEN")).
  3. Node.js: the main file is index.js, and the libraries are in package.json under dependencies. Running, for example, npm install discord.js on your computer puts them there.
  4. Put process.loadEnvFile() at the start of index.js and sign the bot in, for example with client.login(process.env.DISCORD_TOKEN). You don't need any extra package for this.

3. Upload the bot and start it

  1. In the client area open Services, pick your service and click Open game panel.
  2. On the Files tab delete the sample bot.py (for Node.js index.js and package.json): the three dots at the end of the row, Delete. Then click Upload and upload your files. Don't upload the node_modules folder.
  3. Click New File, type the line DISCORD_TOKEN=your_token and click Create File. Type .env in File Name and confirm with Create File.
  4. Is your main file named differently, for example main.py? On the Startup tab enter it in BOT / APP FILE, for Node.js in MAIN FILE.
  5. On the Console tab click Restart (the circular arrow at the top near the server's name). The server first installs the libraries, then starts the bot. On Discord the bot shows as online.

Troubleshooting

The bot says the token is invalid

Check that .env holds the whole token without spaces. After Reset Token only the new token works: put it in .env and restart the bot.

The bot is online but ignores messages

A bot that reads the text of messages needs Message Content Intent. Turn it on in the Developer Portal on the Bot page and allow it in the code too: in discord.py intents.message_content = True, in discord.js GatewayIntentBits.MessageContent. Then restart the bot.

The console says a module is missing

Python prints ModuleNotFoundError, Node.js Cannot find module. Add the library to requirements.txt or to dependencies in package.json and restart the bot. It is installed at start.

The panel keeps showing that the bot is starting

The top near the name shows Starting until the panel finds a word such as ready in the console log. Print it once the bot has signed in, for example print("Bot ready", flush=True) or console.log("Bot ready"). The bot runs normally in the meantime.

Still stuck?

Message us on Discord. The AI assistant Aurel answers first, and you can call an admin. Or open a ticket in the client area.