forked from syntaxbullet/AuroraBot-discord
feat: implement chat XP processing on message create
This commit is contained in:
13
src/index.ts
13
src/index.ts
@@ -2,6 +2,7 @@ import { Events } from "discord.js";
|
||||
import { KyokoClient } from "@lib/KyokoClient";
|
||||
import { env } from "@lib/env";
|
||||
import { userService } from "@/modules/user/user.service";
|
||||
import { levelingService } from "@/modules/leveling/leveling.service";
|
||||
|
||||
// Load commands
|
||||
await KyokoClient.loadCommands();
|
||||
@@ -11,6 +12,18 @@ KyokoClient.once(Events.ClientReady, async c => {
|
||||
console.log(`Ready! Logged in as ${c.user.tag}`);
|
||||
});
|
||||
|
||||
// process xp on message
|
||||
KyokoClient.on(Events.MessageCreate, async message => {
|
||||
if (message.author.bot) return;
|
||||
if (!message.guild) return;
|
||||
|
||||
const user = await userService.getUserById(message.author.id);
|
||||
if (!user) return;
|
||||
|
||||
levelingService.processChatXp(message.author.id);
|
||||
});
|
||||
|
||||
// handle commands
|
||||
KyokoClient.on(Events.InteractionCreate, async interaction => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user