Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Commit

Permalink
Add 51 message logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Ray committed Oct 21, 2018
1 parent 05b6419 commit ae49e0c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions events/message.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The MESSAGE event runs anytime a message is received
// Note that due to the binding of client to every event, every event
// goes `client, other, args` when this function is run.

const Discord = require('discord.js')
module.exports = async (client, message) => {
// It's good practice to ignore other bots. This also makes your bot ignore itself
// and not get into a spam loop (we call that "botception").
Expand Down Expand Up @@ -44,10 +44,10 @@ module.exports = async (client, message) => {
// Some commands may not be useable in DMs. This check prevents those commands from running
// and return a friendly error message.
if (cmd && !message.guild && cmd.conf.guildOnly)
return message.channel.send("This command is unavailable via private message. Please run this command in a guild.");
return message.channel.send('This command is unavailable via private message. Please run this command in a guild.');

if (level < client.levelCache[cmd.conf.permLevel]) {
if (settings.systemNotice === "true") {
if (settings.systemNotice === 'true') {
return message.channel.send(`You do not have permission to use this command.
Your permission level is ${level} **(${client.config.permLevels.find(l => l.level === level).name})**
This command requires level ${client.levelCache[cmd.conf.permLevel]} **(${cmd.conf.permLevel})**`);
Expand All @@ -61,10 +61,25 @@ module.exports = async (client, message) => {
message.author.permLevel = level;

message.flags = [];
while (args[0] && args[0][0] === "-") {
while (args[0] && args[0][0] === '-') {
message.flags.push(args.shift().slice(1));
}
// If the command exists, **AND** the user has permission, run it.
client.logger.cmd(`[CMD] ${client.config.permLevels.find(l => l.level === level).name} ${message.author.username} (${message.author.id}) ran command ${cmd.help.name}`);

const embed = new Discord.RichEmbed();
embed.setTitle('COMMAND EXECUTED');
embed.addField('User', `${message.author.username} \`(${message.author.id})\``, true);
embed.addField('User Permissions', client.config.permLevels.find(l => l.level === level).name, true);
embed.addField('Command', cmd.help.name, true);
try {
embed.addField('Guild', `${message.guild.name} \`(${message.guild.id})\``, true);
embed.addField('Channel', `${message.channel.name} \`(${message.channel.id})\``, true);
} catch (error) {
console.log(error);
}
embed.setFooter(client.user.username, client.user.avatarURL);
embed.setTimestamp();
client.channels.get('503391943452000257').send(embed);
cmd.run(client, message, args, level);
};

0 comments on commit ae49e0c

Please sign in to comment.