Permalink :

Custom SCA Bot Commands
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5


SCA Bot Custom Commands

Some interest has been expressed in creating your own chat commands for SCA-Bot in both Discord and Spectrum, so I've refactored the bot to accept new commands much easier than before.


Each of the bots commands are now made with a single generic node.js file.
For Discord it utilises the Discord.js library. For full documentation on discord.js see here - https://discord.js.org/#/docs/main/stabl...al/welcome


The Spectrum library is nowhere near as feature rich as Discord, as it was custom made by me.
If you want more advanced Spectrum features, suggest them and I might be able to make it happen.

I've made a comment in the .process() function listing all of the Spectrum info & it's functions, they mimmic Discord.js's layout to avoid doubling code where possible. i.e message.author.id is the same on both clients as well as the reply functions, message.reply() & message.author.sendMessage()

Spectrum Embedding

Note that link & image embedding doesn't currently work on Spectrum, they require manual link detection & formatting on the client side and I didn't think it was worth the time coding in right now. If you want to help make this feature work get in contact and I'll explain what needs to happen in greater detail.

The Command File

Below is an example of the <info command. Expand on this however you like to make your commands.
Info.js Download

  Name:     SCA Info
  Command:  <Info
  Description: A command to give basic info about the bot in a message reply.
  Help Message Line: The bot says hi!
// Discord Utilities - Required for Perm Checker
var eDUtils = require('./../Extensions/discord_utils');
// Function for checking perms against the database.
// Returns true if user has access to this command.
var fCheck_Perms_Discord =  eDUtils.fCheck_Perms;

// Mongo DB
// Get the command permission model.
var command_perms = require("./../Models/command.js").Item;

// Command Name
var sName = "info"; // This is the command name. This will respond to <info or >info in chat.

// Command Permission Default. This sets the initial default to be inserted into the database
var oPerms = {
  name : sName,       // Command Name
  discord : true,     // Allow Responses in Discord Guild Chat
  discord_pm : true,  // Allow Responses in Discord Private Message
  rsi : true,         // Allow Responses in Spectrum Guild Message
  rsi_pm : true,      // Allow Responses in Spectrum Private Message
  // Permission Whitelisting
  // "*" for everything.
  guilds : [
    "*" // Array of Guild ID's
  channels : [
    "*" // Array of Channel ID's
  roles : [
    "*" // Array of Role ID's
  users : [
    "*" // Array of User ID's

// Check for Database permissions
// If no permissions are found, create new perms from the defaults.
command_perms.findOne({ name: sName }, function(err, perms) {
  if (err) throw err;
  if (!perms){
    var oN‌ewPerms = new command_perms(oPerms);
    oNewPerms.save(function (err){console.log(err);});
  } else {
    oPerms = perms;

// Message Processor
exports.process = function(payload, message){
  //payload = {db: mongoose DB, discord: Discord js Client, rsi: RSI Client, config: Bot Configuration, dev_mode: Bool, in dev mode t/f};
  var config = payload.config;
  if (fCheck_Perms_Discord(sName, message, oPerms, config)){
    message.reply("Hi! I'm a chat bot for SCA! Send <help for a list of my commands!");
    A discord message will have all of Discord JS's message functions available,
    a spectrum message is much more limited in it's functionality. Make sure to check which Client
    the message has came from when using Discord.js features.

    Functions attached to both Spectrum and Discord.
    message.sendclient          - Either "Discord" or "Spectrum" depending on the service the message is recieved.
    message.content             - The string content of the message.
    message.author.id           - Author Discord/Spectrum number
    message.author.username     - Author Handle / Discord username
    message.author.displayname  - Author Spectrum display name
    message.channel             - Spectrum channel number

    message.reply(message)  - Replies to message in the channel the message came from.
    message.author.sendMessage(message) - Sends message in a DM to the message author.

// Basic GET Commands. Required.
exports.getCommand = function(){return sName;};
exports.getPermissions = function(){return oPerms;};

// Basic SET Commands. Required.
exports.setPermissions = function(new_perms){
  // Export for command permission changing.
  Object.assign(oPerms, new_perms);



Custom SCA Bot-Commander code.

completely undocumented, if you want to make something and have any questions PM me on Discord.

  "mainmenu": {
    isMain: true, // Only true for the main. Yours will either be false or not include this.
      var nowPlaying = "";
      if (globalStorage.nowPlaying.playing){
        nowPlaying = "**Now Playing** :musical_note: \n*"+globalStorage.nowPlaying.title+"* - " + globalStorage.nowPlaying.artist+"\n";

      return "**Welcome to the Southern Cross Alliance Discord!**\n\n"+
      "**Server Admins**: \n<@87368201502982144>\n<@87160656964374528>\n<@89986994486120448>\n\n"+
      "Feel free to contact them if you have any Discord related questions.\n\n"+
      "**RSI Stats**:\nSCA Member Count: "+globalStorage.rsiStats.scaMemberCount+"\nSCA Latest Member: "+globalStorage.rsiStats.scaLatestMember+"\n\nRSI Crowd Funding Total: $"+globalStorage.rsiStats.rsiFunding+"\n\n"+
      "Latest SCA Forum Post: "+globalStorage.forumPost.postLink+"\nBy "+globalStorage.forumPost.postName+"\n```"+globalStorage.forumPost.post+"```\n"+
      "Latest Recruitment Post: "+globalStorage.recruitmentPost.postLink+"\nBy "+globalStorage.recruitmentPost.postName+"\n```"+globalStorage.recruitmentPost.post+"```\n"+
      "\n**Click the respective Reaction to select a menu item.**\n"+dEmoji.objects.link+" - SCA Web Links\n"+dEmoji.symbols.new+" - Subscription Sub/UnSub\n"+dEmoji.nature.cat+"** -** Show a Cat";
    reactionList: [
      {emoji:dEmoji.objects.link, func:function(reaction, user){changeMenu(commands["links"]);}},
      {emoji:dEmoji.symbols.new, func:function(reaction, user){
        changeMenu(commands["memberupdates"], user);
      // Hidden Menu Item. Will function just like any other however it won't add the emoji to the message.
      {emoji:dEmoji.symbols.two, hidden:true, func:function(reaction, user){console.log("Hidden Emoji!");}},
      {emoji:dEmoji.nature.cat, func:function(reaction, user){

Forum Jump:

Users browsing this thread: 1 Guest(s)