This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Objectifs de la PR : - Retirer toute les classes du projet pour plus être orienté vers de la programmation fonctionnelle - Créer un système d'auto-loading beaucoup plus propre avec des fichiers séparer les uns des autres - Utilisation d'arrows functions a la place de regulars functions - Nouvelle convention de nommage des fichiers *(kebab-case, fonctionnalité du fichier défini en `file.functionnalité.ts`, export barrel pour les choses pas auto load)* Pour l'instant les exports sont un peu défini de manière magique, mais dans le futur cette PR viendra fix ça : microsoft/TypeScript#38511
- Loading branch information
Showing
45 changed files
with
270 additions
and
1,919 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,42 @@ | ||
import { Client as DiscordClient, GatewayIntentBits, Guild, Partials, Team, User } from "discord.js"; | ||
import EventManager from "$core/events/EventManager"; | ||
import CommandManager from "$core/commands/CommandManager"; | ||
import TaskManager from "$core/tasks/TaskManager"; | ||
import Logger, { logCrown } from "$core/utils/Logger"; | ||
import { guildId } from "$resources/config/information.json"; | ||
import { version } from "../package.json"; | ||
import { version, displayName } from "../package.json"; | ||
import { getStringEnv } from "./utils/EnvVariable"; | ||
|
||
export default class Client extends DiscordClient { | ||
|
||
public static instance: Client; | ||
|
||
// Events and commands managers : | ||
public readonly eventManager: EventManager; | ||
|
||
public readonly commandManager: CommandManager; | ||
|
||
public readonly taskManager: TaskManager; | ||
|
||
constructor() { | ||
super({ | ||
intents: [ | ||
GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, | ||
GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildMembers, | ||
GatewayIntentBits.GuildMessageReactions, GatewayIntentBits.GuildVoiceStates, | ||
GatewayIntentBits.GuildBans | ||
], | ||
partials: [Partials.Message, Partials.Channel, Partials.Reaction] | ||
}); | ||
|
||
// Create bot instance and login it : | ||
Client.instance = this; | ||
this.login(getStringEnv("BOT_TOKEN")); | ||
|
||
// Load events, commands and tasks managers : | ||
this.eventManager = new EventManager(); | ||
this.commandManager = new CommandManager(); | ||
this.taskManager = new TaskManager(); | ||
} | ||
|
||
public async getGuild() : Promise<Guild> { | ||
return await this.guilds.fetch(guildId); | ||
} | ||
|
||
public getDevTeam() : User[] | null { | ||
const owner = this.application?.owner; | ||
|
||
if (owner instanceof User) { | ||
return [owner]; | ||
} else if (owner instanceof Team) { | ||
return owner.members.map(teamMember => teamMember.user); | ||
} else { | ||
return null; | ||
} | ||
import { guildId } from "$resources/config/information.json"; | ||
import { listener, load, register } from "$core/utils/command"; | ||
|
||
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 getGuild = async(): Promise<Guild> => { | ||
return await client.guilds.fetch(guildId); | ||
}; | ||
|
||
export const getDevTeam = (): 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; | ||
} | ||
}; | ||
|
||
} | ||
(async() => { | ||
logCrown(); | ||
Logger.info(`Sarting ${displayName} v${version}...`); | ||
await client.login(getStringEnv("BOT_TOKEN")); | ||
|
||
logCrown(); | ||
Logger.info(`Sarting Royaume-Discord-Bot V${version}...`); | ||
new Client(); | ||
await load(`${__dirname}\\commands`); | ||
listener(client); | ||
await register(client); | ||
})(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.