Revolt-Bot/src/index.ts

30 lines
884 B
TypeScript
Raw Normal View History

2023-08-20 20:44:16 +02:00
import { Client, Message } from "revolt.js";
import { commandHandler } from "./utils/commandHandler"
import { nonCommandHandler } from "./utils/nonCommandHandler"
2023-08-20 20:44:16 +02:00
import config from "../config.json"
2023-09-04 10:41:08 +02:00
const client : Client = new Client({ eagerFetching: false });
2023-08-20 20:44:16 +02:00
client.on("ready", async () => {
console.info(`Gummed 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
});
client.on("messageCreate", async (message: Message) => {
try{ if (!message.author) { await client.users.fetch(message.authorId) } }
2023-09-05 19:28:54 +02:00
catch(e){console.log(e)}
if (message.content === undefined) {return}
2023-09-04 10:57:25 +02:00
if (message.author?.bot) {}
else {
2023-09-05 20:07:46 +02:00
if (message.content.startsWith(config.prefix)) {
2023-09-05 19:40:46 +02:00
commandHandler(message, config.prefix);
2023-08-20 20:44:16 +02:00
}
2023-09-05 19:40:46 +02:00
else {
nonCommandHandler(message);
}
}
2023-08-20 20:44:16 +02:00
});
client.loginBot(config.botKey);