本文へスキップ

ガイド · Discord Bot

Node.js の Bot をアップロード(discord.js)

index.js + package.json + .env → 起動。

1. Prepare

2. Three files

index.js

require('dotenv').config();
const { Client, Events, GatewayIntentBits, REST, Routes, SlashCommandBuilder } = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const commands = [new SlashCommandBuilder().setName('ping').setDescription('Response time').toJSON()];

client.once(Events.ClientReady, async (c) => {
  await new REST().setToken(process.env.TOKEN).put(Routes.applicationCommands(c.user.id), { body: commands });
  console.log(`Logged in: ${c.user.tag}`);
});

client.on(Events.InteractionCreate, async (i) => {
  if (i.isChatInputCommand() && i.commandName === 'ping') await i.reply(`pong ${client.ws.ping}ms`);
});

client.login(process.env.TOKEN);

package.json

{
  "name": "my-bot",
  "main": "index.js",
  "dependencies": {
    "discord.js": "^14",
    "dotenv": "^16"
  }
}

.env

TOKEN=your_copied_token

3. Upload · start

  1. Service page → Open panel → Files → Upload. Do not upload node_modules.
  2. Console → Start.
  3. Console: package.json 목록을 설치합니다. (installing packages) → 봇을 시작합니다: index.js (starting bot) → Logged in: ….
  4. Run /ping in Discord.

4. Automatic setup

  • Entry file: main in package.json → index.js · main.js · bot.js · app.js (including src/ and .ts) → the only .js file → npm start.
  • Packages: npm install when package.json changes; missing require or import packages are also installed.
  • TypeScript (.ts) runs directly.
  • Set manually: panel Startup → Start file · Additional packages · Packages to remove.

5. Read messages

  1. Developer Portal → Bot → enable Message Content Intent.
  2. Add GatewayIntentBits.GuildMessages · GatewayIntentBits.MessageContent to intents.

6. GitHub (optional)

  • Panel Startup → Git address (private repos: Git username · Git token).
  • With an empty server directory, Settings → Reinstall Server.
  • Auto update 1 → git pull on each start.

すべてのガイド Discord Bot プラン お問い合わせ

提携 봇 제작 외주 이어드림 커스텀 봇 · 컴포넌트 V2 · 웹 · 프로그램 · 로고 · 배너 · UI/UX Discord で問い合わせ