Added Drizzle ORM for Database Connection and Basic Member Command

This commit is contained in:
Ahmad 2024-11-23 15:14:21 -05:00
parent f1e6e05345
commit 9030fbcdcb
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
11 changed files with 1955 additions and 154 deletions

View file

@ -1,12 +1,16 @@
import fs from "node:fs";
import path from "node:path";
import { Client, Collection, Events, GatewayIntentBits } from "discord.js";
import { deployCommands } from "./util/deployCommand.js";
import { getAllMembers, setMembers } from "./util/db.js";
const config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
const { token } = config;
const config = JSON.parse(fs.readFileSync("./config.json", "utf8"));
const { token, guildId } = config;
const client: any = new Client({ intents: [GatewayIntentBits.Guilds] });
const client: any = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
});
client.commands = new Collection();
try {
@ -44,7 +48,13 @@ try {
console.log(`Error while registering commands: ${error}`);
}
client.once(Events.ClientReady, (c: any) => {
client.once(Events.ClientReady, async (c: any) => {
const guild = await client.guilds.fetch(guildId);
const members = await guild.members.fetch();
const nonBotMembers = members.filter((member: any) => !member.user.bot);
await setMembers(nonBotMembers);
console.log(`Ready! Logged in as ${c.user.tag}`);
});