add batching system to guild create

This commit is contained in:
Ean Milligan 2025-05-03 23:21:51 -04:00
parent e5e77189ec
commit 1ea2f64341
1 changed files with 25 additions and 24 deletions

View File

@ -1,37 +1,38 @@
import { DiscordenoGuild, sendMessage } from '@discordeno';
import { DiscordenoGuild, EmbedField, sendMessage } from '@discordeno';
import { log, LogTypes as LT } from '@Log4Deno';
import config from '~config';
import { successColor } from 'embeds/colors.ts';
import { infoColor1 } from 'embeds/colors.ts';
import utils from 'utils/utils.ts';
export const guildCreateHandler = (guild: DiscordenoGuild) => {
log(LT.LOG, `Handling joining guild ${JSON.stringify(guild)}`);
let guildsJoined: EmbedField[] = [];
const sendGuildJoinedBatch = () => {
sendMessage(config.logChannel, {
embeds: [
{
title: 'New Guild Joined!',
color: successColor,
fields: [
{
name: 'Name:',
value: `${guild.name}`,
inline: true,
},
{
name: 'Id:',
value: `${guild.id}`,
inline: true,
},
{
name: 'Member Count:',
value: `${guild.memberCount}`,
inline: true,
title: 'Guild Joined!',
color: infoColor1,
fields: guildsJoined,
},
],
},
],
}).catch((e: Error) => utils.commonLoggers.messageSendError('guildCreate.ts:36', 'Join Guild', e));
}).catch((e: Error) => utils.commonLoggers.messageSendError('guildCreate.ts:21', 'Join Guild', e));
guildsJoined = [];
};
setInterval(() => {
sendGuildJoinedBatch();
}, 60 * 1000);
export const guildCreateHandler = (guild: DiscordenoGuild) => {
log(LT.LOG, `Handling joining guild ${JSON.stringify(guild)}`);
guildsJoined.push({
name: `${guild.name}: (${guild.id})`,
value: `${guild.memberCount}`,
});
if (guildsJoined.length === 25) {
sendGuildJoinedBatch();
}
};