mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-17 01:55:27 +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 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)) {
|
if (!content.startsWith(messageHelper.prefix)) {
|
||||||
await webhookHelper.sendMessageAsMember(client, message).catch((e) => {
|
await webhookHelper.sendMessageAsMember(client, message, content).catch((e) => {
|
||||||
throw e
|
throw e
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -53,9 +53,28 @@ client.on(Events.MessageCreate, async (message) => {
|
|||||||
|
|
||||||
client.on(Events.Ready, () => {
|
client.on(Events.Ready, () => {
|
||||||
console.log(`Logged in as ${client.user?.username}`);
|
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 {
|
try {
|
||||||
await client.login(token);
|
await client.login(token);
|
||||||
// await db.check_connection();
|
// await db.check_connection();
|
||||||
|
|||||||
Reference in New Issue
Block a user