Skip to content

Installation of your discord bot on FPS.MS

The installation differs on the package you choose, currently supported are Python and NodeJS.

Python

Create a file named app.py this is the main entery point of your application.

ATTENTION

Not having this file will result in the error /usr/local/bin/python: can't open file '/home/container/app.py': [Errno 2] No such file or directory!

Here is a example Discord.Py bot from their website:

app.py
# This example requires the 'message_content' intent.

import discord

class MyClient(discord.Client):
  async def on_ready(self):
      print(f'Logged on as {self.user}!')

  async def on_message(self, message):
      print(f'Message from {message.author}: {message.content}')

intents = discord.Intents.default()
intents.message_content = True

client = MyClient(intents=intents)
client.run('my token goes here')

This requires the module discord.py module, you are required to put the requirements inside a text file called requirements.txt or specify in the Startup-tab of your server through the panel.

requirements.txt
discord.py

ATTENTION

Not having this will cause a error ModuleNotFoundError: No module named 'discord'!

Node.js

Make sure to read through the Discord.js documentation on how to create a bot: Discord.js Guide

You have the following methods of using the Node.js bot: (they are in order of ease of development) 1. Create A Github repository with your code locally and go into the startup tab on the panel to fill in your github information. 2. Create your bot locally and then upload through SFTP. 3. Create all files on the panel:

The following steps are partially based on the official Discord.js documentation. Please refer to the documentation if you have further questions!

Create the following files: The package.json is used to install all the dependencies please refer to the

package.json
{
  "name": "fps-nodejs-bot",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "discord.js": "latest"
  }
}
config.json
{
    "token": "your-token-goes-here"
}
index.js
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

// When the client is ready, run this code (only once).
// The distinction between `client: Client<boolean>` and `readyClient: Client<true>` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
    console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});

// Log in to Discord with your client's token
client.login(token);
3. Start your server.