Smile Hosting
इस पेज का अभी हिन्दी में अनुवाद नहीं हुआ है, इसलिए यह अंग्रेज़ी में दिखाया जा रहा है।
Run a Discord bot
Make a bot in Discord, then keep it online on Smile Hosting.
This walks through making a bot from scratch and getting it online. If your bot already works on your own computer, skip to Put it on Smile Hosting.
Make the bot in Discord
- Go to the Discord Developer Portal and click New Application. Give it a name.
- Open the Bot page on the left.
- Click Reset Token, then copy the token that appears. This is your bot’s password - keep it private.
- Still on the Bot page, turn on any Privileged Gateway Intents your code uses. Most bots that read messages need Message Content Intent; bots that track members need Server Members Intent.
- Open OAuth2 > URL Generator, tick bot and applications.commands, pick the permissions your bot needs, and open the link at the bottom to invite it to your Discord server.
ख़तराAnyone with your token can control your bot. Never paste it into Discord, a ticket, or a public GitHub repository. If it leaks, click Reset Token straight away.
A small bot to start from
Node.js (discord.js)
require('dotenv').config();
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once('ready', () => console.log(`Logged in as ${client.user.tag}`));
client.login(process.env.TOKEN);
package.json dependencies: discord.js and dotenv. Put your token in a file called .env:
TOKEN=paste-your-token-here
Python (discord.py)
import os
import discord
from dotenv import load_dotenv
load_dotenv()
client = discord.Client(intents=discord.Intents.default())
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
client.run(os.environ["TOKEN"])
requirements.txt: discord.py and python-dotenv, with the same .env file.
Put it on Smile Hosting
- Create a server with the type Discord Bot.
- On Settings, pick the runtime and make sure the run command matches your main file. See Set up your server.
- Upload your files, including
.env- but notnode_modulesorvenv. - Click Install deps, then Start on the Console tab.
When the console prints Logged in as ..., your bot is online.
सुझावBot won’t log in? See Invalid token and Disallowed intents.