Smile Corp Docs
Français
Smile Hosting
Cette page n'a pas encore été traduite en français, elle est donc affichée en anglais.

Run a Discord bot

Make a bot in Discord, then keep it online on Smile Hosting.

Mis à jour le 12 sept. 20261 min de lecture

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

  1. Go to the Discord Developer Portal and click New Application. Give it a name.
  2. Open the Bot page on the left.
  3. Click Reset Token, then copy the token that appears. This is your bot’s password - keep it private.
  4. 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.
  5. 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.
Danger

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

  1. Create a server with the type Discord Bot.
  2. On Settings, pick the runtime and make sure the run command matches your main file. See Set up your server.
  3. Upload your files, including .env - but not node_modules or venv.
  4. Click Install deps, then Start on the Console tab.

When the console prints Logged in as ..., your bot is online.

Astuce

Bot won’t log in? See Invalid token and Disallowed intents.