Skip to content

Instantly share code, notes, and snippets.

@CayeOficial
Last active April 10, 2024 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CayeOficial/daa85c79bfcfa93f6525017407c657d2 to your computer and use it in GitHub Desktop.
Save CayeOficial/daa85c79bfcfa93f6525017407c657d2 to your computer and use it in GitHub Desktop.
How to install and use my Discord Bot?

How can I install the bot after the purchase?

Requeriments

  • Node.JS +17
  • NPM
  • A hosting service to run the bot 24/7 (you can host it yourself on a VPS or Dedicated server)

Steps

Create the bot's root folder.

For example, it can be called Bot (/home/Bot, /root/Bot, etc)

This is not needed if you are using Pterodactyl or if you are hosting it directly on a Docker Container.

Download the file from BuiltByBit (MC-Market) and unzip it.

Move the file to the bot's root folder (previusly created) and type unzip CustomDiscordCommands.zip to unzip it. (unzip package should have been installed previusly)

If you are using Pterodactyl, simply upload the file to the server's root directory and unarchive it from the file's dropdown menu.

Install dependencies.

  • Make sure that you are using Node.JS version +17. (You can check it with node -v)

Run npm i to install all dependencies from the package.json file.

When it has finished, you can start configuring the bot and creating commands.

Set up the config file

Open the config file and replace token: YOUR-TOKEN with your Discord Bot's token, that can be found here.

You MUST invite the bot to the guild with the application.commands scope and remember to enable Message Content Intent on the Discord Developer Portal

Starting the bot

Type node index.js to start the bot.

Understanding the config file

commands_type: "BOTH"
guild: "Your Main Guild ID"

interaction_commands:
  type: "PRIVATE"

prefix_commands:
  prefix: "!"


presence:
# Valid options: online, dnd, idle, invisible
  status: "online"
# Valid options: PLAYING, LISTENING, STREAMING, WATCHING
  activity_type: "PLAYING"
# This will show if you set activity_type to PLAYING or LISTENING, therefore will end as: Playing/Listening <your_activity_name>
  activity_name: "commands"
# If you've set the activity_type to STREAMING or WATCHING, a valid Twitch URL is required, set it here:
  activity_url: "https://www.twitch.tv/"


messages:
  error:
    description: "There was an error while executing the command. Please check console"
    color: "#FF0000" #RED

  not_allowed_rol:
    description: "You don't have the required role to use this command"
    color: "#FF0000" #RED

  not_allowed_channel:
    description: "You can't use this command here"
    color: "#FF0000" #RED

token: "YOUR-TOKEN"

commands_type: There are 3 options:

Mode Recommended? Meaning
SLASH The bot will only reply to slash commands.
PREFIX The bot will only reply to "prefix" commands.
BOTH ❓ Partially The bot will reply to both slash and prefix commands.

guild: If your bot is private, you have to set your main guild ID here.

interaction_commands.type: If you set it to PRIVATE the bot will only register Slash Commands on the guild specified above. Otherwise, if you want to register Slash Commands on more than one guild, set it to PUBLIC. This option do not make restrictions on "prefix" commands.

prefix_commands.prefix: If you want to use prefix commands (although it is not recommended), you have to set the prefix here.

presence: This is the bot's presence status. Sub-options are self-explanatory.

Option Valid settings
status online, dnd, idle, invisible
activity_type PLAYING, LISTENING, STREAMING, WATCHING
activity_name Anything.
activity_url Valid Twitch Stream URL.

messages: These are the messages that the bot will use on certain times. Message and color is configurable.

token: Here you have to put your bot token. That is explained here.

Creating commands

Slash commands:

  • You can create Slash Commands by copying and pasting the example set on the config.
faq: #<-- Command name goes here
  description: "📚 Shows frequently asked questions."
  content: #Your content goes here. Create your own on https://embeds.cayeoficial.com
  ephemeral: true
  dm_permission: false
  allowed_roles:
    enabled: false
    roles:
      - "ID HERE"
  allowed_channels:
    enabled: false
    channels:
      - "ID HERE"

faq: Replace this text with your command name (accessible through /<command_name>)

description: Add here a brief description of the command.

content: That's the bot command's reply. Get your own at https://embeds.cayeoficial.com

ephemeral: If true, only the user that executes the command will see the reply, useful for long content. Otherwise everyone will see the reply.

dm_permission: Discord allow people to execute commands on DM by default, you can toggle it off by setting it to false.

allowed_roles: If you set enabled to true, only the people who have one or several roles from the specified below will be able to use the command.

allowed_channels: Same as above, if you set enabled to true, the command will be executable only on the channels specified below.

  • TIP: You can set more than one allowed rol/channel

Normal (prefix) commands:

  • You can create Normal Commands by copying and pasting the example set on the config.
  • Be careful, these commands are outdated and not recommended. Also they are less customizable.
faq: #<-- This is the command name. It's accessible through <prefix><command_name>
  content: #Your content goes here. Create your own on https://embeds.cayeoficial.com
  reply: true
  allowed_roles:
    enabled: false
    roles:
      - "ID HERE"
      - "ANOTHER ID HERE"
  allowed_channels:
    enabled: false
    channels:
      - "ID HERE"

faq: Replace this text with your command name (accessible through <prefix><command_name>)

content: That's the bot command's reply. Get your own at https://embeds.cayeoficial.com

reply: If it is set to true, the bot will reply to the original message. Otherwise the bot will send a new message to the channel.

allowed_roles: If you set enabled to true, only the people who have one or several roles from the specified below will be able to use the command.

allowed_channels: Same as above, if you set enabled to true, the command will be executable only on the channels specified below.

  • TIP: You can set more than one allowed rol/channel

Troubleshooting

Error: Cannot find module 'node:events'

  • Your Node.JS version is outdated. You need v17 or newer to use the bot.

Error: Cannot find module 'X' (any other than node:events)

  • Seems to be that you did not installed all dependencies of the bot. Please follow this part of the guide.

Error: Invalid YAML

  • That happens when you have an error on any of the .yml files provided. This has an easy solution, check your YAML file for errors using any Yaml Validator Tool. Honestly, I recommend this one because it shows the reason of the error and how to fix in most of the cases.

Error: Invalid Token Provided

  • This is self-explanatory, however some users may not understand it. If you get this error, means that the token specified on the config is not a valid one. (Needless to say, user tokens cannot be used, as they are denied.)

Error: Unknown interaction

  • Most likely, you have deleted the bot message before it's response is updated. It may mean something else, I recommend contacting support if you didn't do that.

Slash Commands aren't being registered on the server

  • Check if the slashcommands.yml isn't empty and it's permissions are set correctly.
  • Check if the bot have been added to te guild without applications.commands scope.
  • Check if you have any other software that runs with the same token and register another commands or none.
  • Check if the command type is set to SLASH or BOTH
  • If the type of interaction commands is set to PUBLIC, it may took up to an hour to register on all servers. (This is managed by Discord and cannot be speed up)

Support

Still needing help? Reach me out on Discord zCayeOficial#0001

@zzHuerta
Copy link

zzHuerta commented Apr 9, 2024

No puedo cargar el Bot y no me deja enviarte solicitud...

@CayeOficial
Copy link
Author

No puedo cargar el Bot y no me deja enviarte solicitud...

Hola, crea un ticket en mi discord de soporte: https://discord.cayeoficial.com y podré ayudarte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment