created new logging system, also added logging of commands
This commit is contained in:
parent
cb16a007d3
commit
d18afd63f0
4 changed files with 48 additions and 154 deletions
90
src/index.js
90
src/index.js
|
@ -6,6 +6,7 @@ const {
|
|||
Partials,
|
||||
} = require("discord.js");
|
||||
|
||||
const log = require("./util/log.js").execute;
|
||||
const fs = require("fs");
|
||||
|
||||
const client = new Client({
|
||||
|
@ -57,48 +58,30 @@ client.on("messageDelete", async (message) => {
|
|||
const args = message.content.slice(prefix.length).split(/ +/);
|
||||
const command = args.shift().toLowerCase();
|
||||
if (!client.commands.has(command)) {
|
||||
fs.appendFileSync(
|
||||
"../pepperbot/src/logs/deletedmessages.log",
|
||||
"deleted message from: " +
|
||||
message.author.username +
|
||||
"(" +
|
||||
message.author +
|
||||
") at " +
|
||||
Date() +
|
||||
' with: "' +
|
||||
message.content +
|
||||
'"\n'
|
||||
log(
|
||||
"deletedmessages.log",
|
||||
message,
|
||||
__filename,
|
||||
`deleted message from ${message.author.username} (${message.author}) with: "${message.content}"`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
fs.appendFileSync(
|
||||
"../pepperbot/src/logs/deletedmessages.log",
|
||||
"deleted message from: " +
|
||||
message.author.username +
|
||||
"(" +
|
||||
message.author +
|
||||
") at " +
|
||||
Date() +
|
||||
' with: "' +
|
||||
message.content +
|
||||
'"\n'
|
||||
log(
|
||||
"deletedmessages.log",
|
||||
message,
|
||||
__filename,
|
||||
`deleted message from ${message.author.username} (${message.author}) with: "${message.content}"`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
client.on("messageCreate", async (message) => {
|
||||
if (message.channel.type === 1) {
|
||||
fs.appendFileSync(
|
||||
"../pepperbot/src/logs/directmessages.log",
|
||||
"direct message from: " +
|
||||
message.author.username +
|
||||
"(" +
|
||||
message.author +
|
||||
") at " +
|
||||
Date() +
|
||||
' with: "' +
|
||||
message.content +
|
||||
'"\n'
|
||||
log(
|
||||
"directmessages.log",
|
||||
message,
|
||||
__filename,
|
||||
`direct message from ${message.author.username} (${message.author}) with: "${message.content}"`
|
||||
);
|
||||
}
|
||||
if (!message.content.startsWith(prefix)) return;
|
||||
|
@ -116,42 +99,23 @@ client.on("messageCreate", async (message) => {
|
|||
|
||||
if (!client.commands.has(command)) {
|
||||
message.reply("idiot thats not a command");
|
||||
fs.appendFileSync(
|
||||
"../pepperbot/src/logs/failed.log",
|
||||
"invalid command: " + "from: " + message.content + " at " + Date() + "\n"
|
||||
log(
|
||||
"failed.log",
|
||||
message,
|
||||
__filename,
|
||||
`attempt to use invalid command: ${command} by: ${message.author.username} (${message.author})"`
|
||||
);
|
||||
}
|
||||
|
||||
if (client.commands.get(command)) {
|
||||
log(
|
||||
"commands.log",
|
||||
message,
|
||||
__filename,
|
||||
`use of command: ${command} by: ${message.author.username} (${message.author})"`
|
||||
);
|
||||
client.commands.get(command).execute(message, args, client);
|
||||
}
|
||||
});
|
||||
|
||||
client.on("interactionCreate", (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
if (interaction.commandName === "test") {
|
||||
interaction.reply(
|
||||
"mothafucka you contacted my ass from a slash command end urself"
|
||||
);
|
||||
}
|
||||
|
||||
if (interaction.commandName === "say") {
|
||||
try {
|
||||
const msg = interaction.options.get("message");
|
||||
interaction.reply(msg.value);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
fs.appendFile(
|
||||
"../pepperbot/src/logs/errors.log",
|
||||
error + "from: " + interaction.msg + " at " + Date()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (interaction.commandName === "commands") {
|
||||
client.commands.get("commands").execute(interaction, undefined);
|
||||
}
|
||||
});
|
||||
|
||||
client.login(process.env.TOKEN);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue