Discord Bots

Our Plans Features

Documentation

Everything you need to deploy and manage your Discord bots on BotHost.

Quick Start

Welcome to BotHost! This guide will walk you through deploying your first Discord bot in minutes.

  1. Create an account on BotHost and log in to your dashboard.
  2. Create a new bot by clicking "New Bot" and choose your language (Python or Node.js).
  3. Upload your files via the interface or connect your GitHub repository.
  4. Configure your environment variables (TOKEN, etc.).
  5. Deploy and your bot is online!
Astuce

You can try for free for 7 days with our Starter plan, no credit card required!

Create a Discord Bot

Before deploying on BotHost, you need to create a Discord application:

  1. Go to the Discord Developer Portal.
  2. Click "New Application" and give your bot a name.
  3. Go to the "Bot" tab and click "Add Bot".
  4. Copy your bot's Token (keep it secret!).
  5. In "OAuth2 > URL Generator", select the required scopes and permissions.
  6. Use the generated URL to invite the bot to your server.
Important

Never share your token! If your token is compromised, regenerate it immediately on the Developer Portal.

Deploy Your Bot

Once your files are ready, here's how to deploy them on BotHost:

Via the web interface

  1. Go to your bot in the dashboard.
  2. Click "Files" then "Upload".
  3. Select your files or drag and drop them.
  4. Click "Deploy".

Via GitHub (recommended)

  1. Connect your GitHub account in settings.
  2. Select your repository and branch.
  3. Enable automatic deployment (optional).
  4. Each push will trigger a new deployment.

Python Bots

BotHost supports Python 3.10+ with major Discord libraries.

Recommended structure

# Structure de fichiers my-bot/ ├── main.py # Point d'entrée ├── requirements.txt # Dépendances ├── cogs/ # Commandes (optionnel) └── utils/ # Utilitaires (optionnel)

requirements.txt

discord.py>=2.0.0 python-dotenv aiohttp

Exemple de bot

import discord from discord.ext import commands import os bot = commands.Bot( command_prefix="!", intents=discord.Intents.all() ) @bot.event async def on_ready(): print(f"✅ Connecté en tant que {bot.user}") @bot.command() async def ping(ctx): await ctx.send(f"🏓 Pong! {round(bot.latency * 1000)}ms") bot.run(os.getenv("DISCORD_TOKEN"))

Node.js Bots

BotHost supports Node.js 18+ with discord.js v14.

Recommended structure

# Structure de fichiers my-bot/ ├── index.js # Point d'entrée ├── package.json # Dépendances ├── commands/ # Commandes slash └── events/ # Événements

package.json

{ "name": "my-discord-bot", "version": "1.0.0", "main": "index.js", "scripts": { "start": "node index.js" }, "dependencies": { "discord.js": "^14.0.0", "dotenv": "^16.0.0" } }

Exemple de bot

const { Client, GatewayIntentBits } = require('discord.js'); require('dotenv').config(); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent ] }); client.on('ready', () => { console.log(`✅ Connecté en tant que ${client.user.tag}`); }); client.on('messageCreate', async (message) => { if (message.content === '!ping') { await message.reply(`🏓 Pong! ${client.ws.ping}ms`); } }); client.login(process.env.DISCORD_TOKEN);

Environment Variables

Environment variables allow you to securely store sensitive data like your Discord token.

Add variables

  1. Go to your bot in the dashboard.
  2. Click "Settings" then "Environment Variables".
  3. Add your variables (key/value).
  4. Redeploy your bot to apply changes.
Common variables

DISCORD_TOKEN - Your Discord bot token
PREFIX - Command prefix (!)
DATABASE_URL - Database connection URL

Logs & Monitoring

Monitor your bot's activity in real time with logs.

Access logs

  1. Open your bot's dashboard.
  2. Click on the "Logs" tab.
  3. Logs are displayed in real time.

Best practices

  • Use print() in Python or console.log() in JS for debugging.
  • Avoid logging sensitive information (tokens, passwords).
  • Use prefixes to differentiate log types ([INFO], [ERROR], etc.).

Troubleshooting

Here are the most common issues and their solutions:

❌ My bot won't start

  • Check that the main file is properly named (main.py or index.js).
  • Check that DISCORD_TOKEN is configured in environment variables.
  • Check the logs to identify the error.

❌ "Token invalid" error

  • Verify that the token is correct and complete.
  • Regenerate the token on the Discord Developer Portal if needed.
  • Make sure there are no extra spaces or characters.

❌ Bot disconnects frequently

  • Check that you haven't exceeded your plan's resource limits.
  • Optimize your code to reduce memory usage.
  • Consider upgrading to a higher plan.

❌ Dependencies won't install

  • Check the syntax of your requirements.txt or package.json.
  • Make sure versions are compatible.
  • Try specifying exact versions.
Besoin d'aide ?

If you can't find the solution to your problem, feel free to contact our support or join our Discord server.