First implementation
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { Client, Events, GatewayIntentBits } from 'discord.js';
|
||||
import { CommandService } from './services/cmd/service';
|
||||
import RoleService from './services/role/service';
|
||||
|
||||
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
|
||||
|
||||
// Services
|
||||
const commandService = new CommandService(client);
|
||||
const roleService = new RoleService(client);
|
||||
|
||||
client.once(Events.ClientReady, async (readyClient) => {
|
||||
// Initialize & validate
|
||||
await commandService.init();
|
||||
roleService.validate();
|
||||
|
||||
// Ready!
|
||||
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
|
||||
});
|
||||
|
||||
client.on("guildMemberAdd", async (guildMember) => {
|
||||
await roleService.addStarterRoles(guildMember);
|
||||
});
|
||||
|
||||
client.on("messageCreate", async (message) => {
|
||||
if (message.author.bot) return;
|
||||
|
||||
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"]);
|
||||
if (!lurkerRole) continue;
|
||||
|
||||
await guild.members.prune({ days: 5, roles: [lurkerRole] });
|
||||
}
|
||||
});
|
||||
|
||||
client.login(Bun.env.DISCORD_TOKEN);
|
||||
Reference in New Issue
Block a user