King's Domain Logo

King'sDomain

Introduction to Bot Hosting

Welcome to Bot Hosting! This service is designed to run your custom-coded bots 24/7, even when your computer is turned off. A bot is just a program that automates tasks on platforms like Discord or Telegram. By hosting your bot with us, it remains online and available to users around the clock.

Acceptable Use Policy & Resource Limits

Our bot hosting service is strictly intended for running bots on their designated platforms (e.g., a Discord bot connecting to the Discord API). Any attempt to use this service for other purposes (like hosting websites, game servers, or malicious applications) will result in immediate suspension.

Free plans come with specific resource limits (e.g., 256MB RAM, 25% CPU). If your bot grows very large or joins thousands of servers, you may need to upgrade to a paid plan for more power.

Getting Your Bot Token

A "token" is a unique, secret password that your code uses to log in to your bot account. This is the most critical piece of information you need. You must never share your token with anyone.

Discord Bot Token

Create an Application

Go to the Discord Developer Portal and click "New Application". Give it a name and click "Create".

Create a Bot User & Get Token

In your application's settings, go to the "Bot" tab. Click "Add Bot". Under your bot's username, click "Reset Token" to reveal and copy your token.

Enable Gateway Intents

Intents are permissions your bot needs to receive certain types of information. On the same "Bot" page, scroll down and enable all three "Privileged Gateway Intents". Without these, your bot will not be able to see who is in a server, when new members join, or read the content of messages.

Telegram Bot Token

  1. Find BotFather: Open your Telegram app and search for the verified user @BotFather.
  2. Create a New Bot: Start a chat with BotFather and send the command /newbot. Follow the on-screen instructions.
  3. Copy Your Token: Once complete, BotFather will provide your API token. Copy this and save it somewhere secure.

The Pterodactyl Environment for Bots

Our panel provides a powerful, isolated environment to manage your bot. Here are the key concepts explained simply.

Key Startup Variables

The "Startup" tab is where you configure your server. For bots, these are the most important variables:

  • BOT_TOKEN: The secure place where you will paste your secret bot token.
  • BOT_JS_FILE / BOT_PY_FILE: The name of your main script file (e.g., index.js or bot.py).
  • NODE_VERSION (for JavaScript bots): Allows you to specify the version of Node.js to use (e.g., 16, 18, 20). This is crucial for ensuring compatibility with your code and libraries.

Environment Variables: The Secure Way

Pasting your token directly into your code is like writing your password on a sticky note. An **environment variable** is like a secure locker. You place your token in the BOT_TOKEN variable in the Startup tab, and your code can then ask for the value from inside the locker without anyone else seeing it. This is the professional and secure way to handle secrets.

Discord.js (JavaScript) Guide

This guide will walk you through deploying a Discord bot written in JavaScript using the popular discord.js library.

1. The `package.json` File: Your Bot's Shopping List

This file is essential. It tells our server which Node.js libraries (dependencies) to install. Think of it as a shopping list for `npm` (Node Package Manager). You can create it on your PC by running npm init -y in your project folder. It must contain a "start" script and list discord.js in its dependencies.

2. Code Example: A Simple Ping Bot

Your code must read the token from the environment and request the correct "Intents" from Discord to function.

// index.js
const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent
    ]
});

client.on('messageCreate', message => {
    if (message.author.bot) return;
    if (message.content === '!ping') {
        message.reply('Pong!');
    }
});

const token = process.env.BOT_TOKEN;
client.login(token);

3. Deployment Steps

  1. Upload your index.js and package.json files to the File Manager.
  2. Go to the "Startup" tab. Paste your token into the BOT_TOKEN variable. Ensure the BOT_JS_FILE variable is set to index.js.
  3. Start the server. The console will first show npm install running, then your bot will come online.

4. Troubleshooting

"Error: Cannot find module 'discord.js'": This means your package.json file is missing, incorrect, or wasn't uploaded. Make sure it exists and correctly lists `discord.js` under `dependencies`.

"TypeError: Cannot read properties of null (reading 'channels')": This is a classic "Intents" issue. Make sure you have enabled all Privileged Gateway Intents in the Discord Developer Portal.

Discord.py (Python) Guide

This guide covers deploying a Discord bot written in Python using libraries like discord.py or its forks (py-cord, nextcord).

1. The `requirements.txt` File: Python's Shopping List

Our server uses this file to install the necessary Python packages using `pip`. On your PC, generate this file by running this command in your project's terminal:

pip freeze > requirements.txt

2. Code Example: A Better Ping Bot with Commands

While a simple `on_message` event works, the proper way to build a scalable bot is with the `commands` extension.

# bot.py
import os
import discord
from discord.ext import commands

# Intents are permissions. message_content is needed to read commands.
intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

@bot.command()
async def ping(ctx):
    """Replies with Pong!"""
    await ctx.send('Pong!')

# This is the secure way to get your token
token = os.getenv("BOT_TOKEN")
bot.run(token)

3. Advanced: Organizing with Cogs

For larger bots, you should organize your commands into separate files called "Cogs". Create a folder named `cogs`, and inside, create a file like `fun.py`:

# cogs/fun.py
from discord.ext import commands

class Fun(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def hello(self, ctx):
        await ctx.send(f'Hello {ctx.author.name}!')

async def setup(bot):
    await bot.add_cog(Fun(bot))

Then, in your main `bot.py`, you load this cog:

# bot.py (modified to load cogs)
# ... (imports and bot setup as before) ...

@bot.event
async def on_ready():
    print(f'Logged in as {bot.user}')
    await bot.load_extension('cogs.fun')

token = os.getenv("BOT_TOKEN")
bot.run(token)

4. Deployment Steps

  1. Upload your `bot.py`, `requirements.txt`, and your `cogs` folder to the File Manager.
  2. Go to the "Startup" tab. Paste your token into the BOT_TOKEN variable. Ensure the BOT_PY_FILE variable is set to bot.py.
  3. Start the server. The console will show pip install -r requirements.txt running, and then your bot will start.

Telegram Bot Guide

Hosting a Telegram bot follows the exact same principles. You prepare your code to read the token from an environment variable and provide a dependency file.

Python Telegram Bot Example

This example uses the popular python-telegram-bot library.

# requirements.txt
python-telegram-bot==20.3
# main.py
import os
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes

async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
    await update.message.reply_text('Hello from your hosted bot!')

def main() -> None:
    token = os.getenv("BOT_TOKEN") # Securely reads the token
    application = Application.builder().token(token).build()
    application.add_handler(CommandHandler("start", start))
    
    # This constantly asks Telegram for new messages
    application.run_polling()

if __name__ == "__main__":
    main()

To deploy this, you would upload `main.py` and `requirements.txt`, set your `BOT_TOKEN` in the Startup tab, and ensure the Python script name is set to `main.py`.