Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
client: restore
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluzzi committed Apr 3, 2023
1 parent cbc4814 commit 005fc21
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Client as DiscordClient, GatewayIntentBits, Partials, Team, User } from "discord.js";
import { logger } from "$core/utils/logger";
import { version, displayName } from "../package.json";
import { getStringEnv } from "./utils/env-variable";
import { listener, load as loadCommands, register } from "$core/utils/handler/command";
import { load as loadEvents } from "$core/utils/handler/event";
import { load as loadTasks } from "$core/utils/handler/task";

export const client = new DiscordClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildMessages
],
partials: [Partials.Message, Partials.Channel, Partials.Reaction]
});

export const getDevTeam = (client: DiscordClient): User[] | null => {
const owner = client.application?.owner;

if (owner instanceof User) {
return [owner];
} else if (owner instanceof Team) {
return owner.members.map(teamMember => teamMember.user);
} else {
return null;
}
};


logger.info(`Sarting ${displayName} v${version}...`);
client.login(getStringEnv("BOT_TOKEN"));
client.on("ready", async client => {
const eventsLoaded = await loadEvents(client, `${__dirname}\\events`);

logger.info(`${eventsLoaded} events loaded`);

const tasksLoaded = await loadTasks(`${__dirname}\\tasks`);

logger.info(`${tasksLoaded} tasks loaded`);

const loadedCommands = await loadCommands(`${__dirname}\\commands`);

logger.info(`${loadedCommands.builders.size} commands loaded`);

listener(client, loadedCommands.commands);
await register(client, loadedCommands.builders, loadedCommands.guildCommands);

logger.info("Successfully registered application (/) commands");
logger.success("Client has been started");
});

0 comments on commit 005fc21

Please sign in to comment.