The installation differs on the package you choose, currently supported are Python and NodeJS.
Python
Create a file namedapp.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!py title="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')
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
Using Typescript
To host your TS bot, Please compile it down in JS to use it on fps.
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)
- Create A Github repository with your code locally and go into the startup tab on the panel to fill in your github information.
- Create your bot locally and then upload through SFTP.
- Create all files on the panel:
ATTENTION
Don't include the node_modules & npm cache folders, they would be generated by own!
package.json file is used to install all the dependencies. Upload the package.json file of your bot, and FPS will automatically install all the required dependencies. Here's a sample:
package.json
{
"name": "fps-nodejs-bot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node ."
},
"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 <code>client: Client and readyClient: Client 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);
- Start your server.