Skip to content

raddzz/HCS_Bot

Repository files navigation

HCS_Bot

Setup

First, ensure you have node installed. Then clone the repository to your local PC.

Navigate to the /HCS_Bot/ directory in the terminal, and install the required dependencies by running the commands found in the npm_install file.

Rename example_secrets.json to secrets.json and fill in your discord bot token, and ical link.

You should now be able to run the bot by typing "node ." into your terminal.

Working on the bot

  • Commands

To add a command to the bot, you must create a file in the /commands/ directory. The name can be anything, and will be what the user types to run the command.

Within the newly created file, you will need to add some code so that the program knows where to enter the file. To do this, you can copy paste the following:

exports.run = function(bot, message, args){
    //Command functionality goes here
}

exports.props = {
    usage: "",
    description: ""
}

The bot argument contains the client instance of the bot. You are able to access the config file with bot.config

The message argument is the instance of the message generated by discord.js

The args argument is a text array containing all words in the users message, excluding the first one (aka the command name)

  • Events

To add a new Event to the bot, you must create a file in the /events/ directory with the same name as the discord event you want to create.

Within the newly created file, you will need to add some code so that the program can set up the event. To do this, you can copy paste the following:

//global variables
let bot, config;

//initialising the event
exports.init = function (client) {
    bot = client;
    config = client.config;
}

exports.run = async function () {
    //code to execute on the event call goes here
}
  • Utilities

General Utilities should be placed in the /utils/ directory. Utilities should be initialised as an export eg:

  • exports.functionName = function(args){code}
  • exports.variableName = "some value or function call here"

Anything that is not an export is private and only accessible inside the file.

To use one of these utils in a command or event, simply require it as follows:

const {functionName, variableName} = require("../utils/fileName");

:)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published