Introduction

  • Before you start coding, you need to set up your bot properly on Discord. First, it’s necessary to have a Discord account. If you don’t have one yet, you can create one by visiting the official Discord website.
  • Next, you will need to create an account on Square Cloud, which can be done through the login page. You can use either your email or Discord, or both, to create an account.
  • Finally, you need to have an active paid plan on your account. You can view our plans and purchase one according to your needs here.
Remember to keep your bot’s token secret as it can be used to control your bot.

Using wrappers for bot creation

  1. Ensure you have Node.js installed on your system. If not, you can download it from the official Node.js website.
  2. Initialize a new Node.js project using npm init. This will create a new package.json file for your project:
npm init -y
  1. Install the discord.js library using npm:
npm install discord.js
  1. Create a new JavaScript file (e.g., index.js) and add the following code to create a basic Discord bot:
index.js
const { Client, GatewayIntentBits } = require("discord.js");

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
  ],
});

client.on("ready", () => {
  console.log(`${client.user.tag}!`);
});

client.on("messageCreate", (message) => {
  if (message.content === "!hello") {
    message.reply("Hello!");
  }
});

client.login("your token here");

Creating the squarecloud config file

Learn about: how to make the configuration file for Square Cloud.

The squarecloud.app file is a configuration file that will be used to configure your application; it will be used to define the name, description, version, main file, among other things.

Configuring the START Field

Only use this field if you are really sure about what you are doing.

In the Square Cloud configuration file, the START field is optional and only needed if you are using a custom script to start the bot. In the provided example, the START field is not necessary.

Uploading your project to Square Cloud

After following all the steps, package your application files into a zip file where the configuration file is and upload the bot at Upload. Remember to include the requirements.txt or package.json file, but do not include files like __pycache__ or node_modules. You can get more information about unnecessary files when hosting at automatic-file-deletion-when-deploying-an-application-on-squarecloud.

Testing the Bot

If you’ve done everything correctly, the next step is to invite your bot for testing. To do this, follow these steps:

  1. Access the Developer Portal.
  2. Select your bot.
  3. Navigate to the “OAuth2” tab.
  4. Go to “OAuth2 URL Generator”.
  5. Check the “bot” option.
  6. Choose the permissions your bot will have if it’s invited using this invite.
  7. Below the permissions, an invite link for your bot will be generated. It should look something like this:
https://discord.com/oauth2/authorize?client_id=00000000000000&permissions=8&scope=bot

Remember, the client_id in the URL should be replaced with your bot’s actual client ID. The permissions value may also need to be adjusted based on the permissions you want your bot to have.

Now, to test if everything is working, execute the following command on your server: !hello.

Additional Resources

For more information on creating bots with discord.py and discord.js, visit the official discord.py documentation and the official discord.js guide. There, you’ll find detailed guides, tutorials, and API documentation to help you make the most of these libraries.

If you continue to experience any issues, please don’t hesitate to contact our support team.