Klyde
Klyde
DIAdiscord.js - Imagine an app
Created by Klyde on 4/20/2024 in #djs-questions
How do I create a Logger for every event?
I'm trying to create a logger for every event I cover, I alredy did it in the past but it was a bit messy. I had many lines of code in the events files. I was wondering if there was a better and cleaner way of doing so. I thought I (maybe) use a somewhat revisited event handler like the one I'm using:
async function registerEvents(client, dir) {
let files = await fs.readdir(path.join(__dirname, dir));
for (let file of files) {
let stat = await fs.lstat(path.join(__dirname, dir, file));
if (stat.isDirectory()) {
registerEvents(client, path.join(dir, file));
} else {
if (file.endsWith('.js')) {
let eventName = file.substring(0, file.indexOf('.js'));
try {
let eventModule = require(path.join(__dirname, dir, file));
if (eventModule.once) {
client.once(eventName, eventModule.bind(null, client));
} else {
client.on(eventName, eventModule.bind(null, client));
};
} catch(err) {
console.log(err);
};
};
};
};
};
async function registerEvents(client, dir) {
let files = await fs.readdir(path.join(__dirname, dir));
for (let file of files) {
let stat = await fs.lstat(path.join(__dirname, dir, file));
if (stat.isDirectory()) {
registerEvents(client, path.join(dir, file));
} else {
if (file.endsWith('.js')) {
let eventName = file.substring(0, file.indexOf('.js'));
try {
let eventModule = require(path.join(__dirname, dir, file));
if (eventModule.once) {
client.once(eventName, eventModule.bind(null, client));
} else {
client.on(eventName, eventModule.bind(null, client));
};
} catch(err) {
console.log(err);
};
};
};
};
};
But I can't really see how
4 replies
DIAdiscord.js - Imagine an app
Created by Klyde on 9/4/2022 in #djs-questions
How and when is considered API spam?
I see a lot of big bot doing big things like sending to a thousands of people a pm, and when I want do a thing like that I'm afraid to get my bot banned. I want to know when a bot can be banned or warned so I can avoid be afraid.
14 replies
DIAdiscord.js - Imagine an app
Created by Klyde on 7/28/2022 in #djs-questions
UNDERLINES CHANGES BETWEEN VERSIONS
I read on another discord a person who asked if there was a tool or something similar that highlights all the codes that have been changed with the new version of discord, does anyone know if there is such a thing?
4 replies