Browse Source

Add client as a parameter to command invokation

master
benji7425 4 years ago
parent
commit
0c2eafcb6c
  1. 4
      discord-bot-core/HandleMessage.js
  2. 2
      discord-bot-core/client.js
  3. 3
      discord-bot-core/package.json

4
discord-bot-core/HandleMessage.js

@ -2,7 +2,7 @@
const ParentPackageJSON = require("../package.json");
/**@param param*/
function handleMessage(message, commands, guildData) {
function handleMessage(client, message, commands, guildData) {
if (!message.content.startsWith(message.guild.me.toString())) //criteria for a command is the bot being tagged
return;
@ -17,7 +17,7 @@ function handleMessage(message, commands, guildData) {
else if (params.length < command.expectedParamCount)
message.reply(`Incorrect syntax!\n**Expected:** *${botName} ${command.syntax}*\n**Need help?** *${botName} help*`);
else if(isMemberAdmin || !command.admin)
command.invoke({ message, params, guildData });
command.invoke({ message, params, guildData, client });
}
/**@param param*/

2
discord-bot-core/client.js

@ -48,7 +48,7 @@ module.exports = class Client extends Discord.Client {
onMessage(message) {
if (message.channel.type === "text" && message.member)
HandleMessage(message, this.commands, this.guildsData[message.guild.id] || new this.guildDataModel(message.guild.id));
HandleMessage(this, message, this.commands, this.guildsData[message.guild.id] || new this.guildDataModel(message.guild.id));
}
onDebug(info) {

3
discord-bot-core/package.json

@ -5,7 +5,8 @@
"discord.js": "11.2.0",
"jsonfile": "3.0.1",
"parent-package-json": "2.0.1",
"simple-file-writer": "2.0.0"
"simple-file-writer": "2.0.0",
"require-all": "2.2.0"
},
"name": "discord-bot-core",
"repository": {

Loading…
Cancel
Save