committed event scripts (forgot to last time)

This commit is contained in:
ayeuhugyu 2023-09-16 07:27:05 -07:00
parent 1b03b8ca15
commit 5b2bd43069
5 changed files with 99 additions and 0 deletions

View file

@ -0,0 +1,14 @@
const fs = require("fs");
module.exports.execute = function (member) {
if (member.guild.id === "1112819622505365556") {
fs.appendFileSync(
"../pepperbot/data/guildmembers.log",
member.user.username + ` -- added by bot: ${Date()} \n`
);
const channel = client.channels.cache.get("1148814162273763418");
channel.send(
`added new guild member ${member.user.username} (${member.user.id}) to members list`
);
}
};

View file

@ -0,0 +1,6 @@
module.exports = {
guildMemberAdd: require("./guildMemberAdd.js").execute,
messageCreate: require("./messageCreate.js").execute,
messageDelete: require("./messageDelete.js").execute,
ready: require("./ready.js").execute,
};

View file

@ -0,0 +1,62 @@
require("dotenv").config();
const log = require("../util/log.js").execute;
const fs = require("fs");
const discord = require("discord.js");
commands = new discord.Collection();
const commandFiles = fs
.readdirSync("src/commands/")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
(async () => {
const command = await import(`../commands/${file}`);
commands.set(command.default.name, command.default);
})();
}
const prefix = process.env.PREFIX;
module.exports.execute = function (message, client) {
if (message.channel.type === 1) {
log(
"directmessages.log",
message,
__filename,
`direct message from ${message.author.username} (${message.author}) with: "${message.content}"`
);
}
if (!message.content.startsWith(prefix)) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
/*if (message.channelId !== "1148814162273763418") {
let text = "commands only work in <#1148814162273763418>";
if (!client.commands.has(command)) {
text += ", also thats not a command lmao";
}
message.reply(text);
return;
}*/
if (!commands.has(command)) {
message.reply("idiot thats not a command");
log(
"failed.log",
message,
__filename,
`attempt to use invalid command: ${command} by: ${message.author.username} (${message.author})"`
);
}
if (commands.get(command)) {
log(
"commands.log",
message,
__filename,
`use of command: ${command} by: ${message.author.username} (${message.author})"`,
true
);
commands.get(command).execute(message, args, client);
}
};

View file

@ -0,0 +1,10 @@
const log = require("../util/log.js").execute;
module.exports.execute = function (message) {
log(
"deletedmessages.log",
message,
__filename,
`deleted message from ${message.author.username} (${message.author}) with: "${message.content}"`
);
};

7
src/events/ready.js Normal file
View file

@ -0,0 +1,7 @@
const log = require("../util/log.js").execute;
module.exports.execute = function (client) {
console.log(`${client.user.tag} is online.`);
const channel = client.channels.cache.get("1148814162273763418");
channel.send("pepperbot restart complete");
};