mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-14 20:15:28 +10:00
added debounce to count guilds properly
This commit is contained in:
23
src/bot.js
23
src/bot.js
@@ -26,7 +26,7 @@ client.on(Events.MessageCreate, async (message) => {
|
||||
|
||||
// If message doesn't start with the bot prefix, it could still be a message with a proxy tag. If it's not, return.
|
||||
if (!content.startsWith(messageHelper.prefix)) {
|
||||
await webhookHelper.sendMessageAsMember(client, message).catch((e) => {
|
||||
await webhookHelper.sendMessageAsMember(client, message, content).catch((e) => {
|
||||
throw e
|
||||
});
|
||||
return;
|
||||
@@ -53,9 +53,28 @@ client.on(Events.MessageCreate, async (message) => {
|
||||
|
||||
client.on(Events.Ready, () => {
|
||||
console.log(`Logged in as ${client.user?.username}`);
|
||||
console.log(`Serving ${client.guilds.size} guild(s)`);
|
||||
});
|
||||
|
||||
let guildCount = 0;
|
||||
client.on(Events.GuildCreate, () => {
|
||||
guildCount++;
|
||||
callback();
|
||||
});
|
||||
|
||||
function printGuilds() {
|
||||
console.log(`Serving ${client.guilds.size} guild(s)`);
|
||||
}
|
||||
|
||||
const callback = Debounce(printGuilds, 2000);
|
||||
|
||||
function Debounce(func, delay) {
|
||||
let timeout = null;
|
||||
return function (...args) {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func(...args), delay);
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
await client.login(token);
|
||||
// await db.check_connection();
|
||||
|
||||
Reference in New Issue
Block a user