Improve service handling
This commit is contained in:
+9
-11
@@ -1,36 +1,34 @@
|
||||
import { Client, Events, GatewayIntentBits } from 'discord.js';
|
||||
import { CommandService } from './cmd/service';
|
||||
import RoleService from './services/role';
|
||||
import CommandService from './services/command';
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
|
||||
|
||||
// Services
|
||||
const commandService = new CommandService(client);
|
||||
const roleService = new RoleService(client);
|
||||
const client = new Client({
|
||||
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
|
||||
});
|
||||
|
||||
client.once(Events.ClientReady, async (readyClient) => {
|
||||
// Initialize & validate
|
||||
await commandService.init();
|
||||
roleService.validate(client.guilds.cache);
|
||||
await CommandService.init();
|
||||
RoleService.validate(client.guilds.cache);
|
||||
|
||||
// Ready!
|
||||
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
|
||||
});
|
||||
|
||||
client.on("guildMemberAdd", async (guildMember) => {
|
||||
await roleService.giveStarterRoles(guildMember);
|
||||
await RoleService.giveStarterRoles(guildMember);
|
||||
});
|
||||
|
||||
client.on("messageCreate", async (message) => {
|
||||
if (message.author.bot) return;
|
||||
|
||||
const command = commandService.parse(message);
|
||||
const command = CommandService.parse(message);
|
||||
if (command) command.execute(message);
|
||||
});
|
||||
|
||||
Bun.cron("0 */6 * * *", async () => {
|
||||
for (const guild of client.guilds.cache.values()) {
|
||||
const lurkerRole = roleService.getRoleByName(guild, RoleService.ROLES["LURKER"]?.name);
|
||||
const lurkerRole = RoleService.getRoleByName(guild, RoleService.ROLES["LURKER"]?.name);
|
||||
if (!lurkerRole) continue;
|
||||
|
||||
await guild.members.prune({ days: 5, roles: [lurkerRole] });
|
||||
|
||||
Reference in New Issue
Block a user