2023-08-20 20:44:16 +02:00
|
|
|
import { Client, Message } from "revolt.js";
|
|
|
|
import { commandHandler } from "./utils/commandHandler"
|
2023-09-02 23:21:55 +02:00
|
|
|
import { nonCommandHandler } from "./utils/nonCommandHandler"
|
2024-03-15 23:20:11 +01:00
|
|
|
import { Database } from "bun:sqlite";
|
2023-08-20 20:44:16 +02:00
|
|
|
import config from "../config.json"
|
2024-03-15 19:57:42 +01:00
|
|
|
import dbInit from "utils/dbInit";
|
2023-08-20 20:44:16 +02:00
|
|
|
|
2024-03-15 18:41:08 +01:00
|
|
|
const client : Client = new Client({ eagerFetching: false });
|
|
|
|
const db = new Database(config.databaseName);
|
2024-03-15 19:57:42 +01:00
|
|
|
dbInit(db);
|
2023-08-20 20:44:16 +02:00
|
|
|
|
|
|
|
client.on("ready", async () => {
|
2024-03-15 18:41:08 +01:00
|
|
|
console.info(`logged in as ${client.user.username}!`)
|
|
|
|
client.user.edit(
|
|
|
|
{
|
|
|
|
status : {
|
|
|
|
text: config.prefix + " help for the help menu"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2023-08-20 20:44:16 +02:00
|
|
|
});
|
|
|
|
|
2024-03-15 18:41:08 +01:00
|
|
|
|
2023-08-20 20:44:16 +02:00
|
|
|
client.on("messageCreate", async (message: Message) => {
|
2023-12-09 22:46:55 +01:00
|
|
|
try{ if (!message.author) { await client.users.fetch(message.authorId) } }
|
2023-09-05 19:28:54 +02:00
|
|
|
catch(e){console.log(e)}
|
2023-09-07 15:18:21 +02:00
|
|
|
|
2023-09-07 15:41:29 +02:00
|
|
|
if (message.content === undefined) {return}
|
2024-03-15 18:41:08 +01:00
|
|
|
if (message.author?.bot) {return}
|
|
|
|
|
|
|
|
// checks if the message's body starts with the prefix
|
|
|
|
if (message.content.startsWith(config.prefix)) {
|
|
|
|
commandHandler(message, db, config.prefix);
|
|
|
|
}
|
2023-09-04 10:57:25 +02:00
|
|
|
else {
|
2024-03-15 18:41:08 +01:00
|
|
|
nonCommandHandler(message, db);
|
2023-09-05 19:40:46 +02:00
|
|
|
}
|
2023-08-20 20:44:16 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
client.loginBot(config.botKey);
|