Adds deployment for icons

This commit is contained in:
Michel Fedde 2025-05-23 21:41:04 +02:00
parent 154002f6f3
commit 0e10ea3cab
14 changed files with 1449 additions and 53 deletions

View file

@ -7,16 +7,23 @@ import {Container} from "./Container/Container";
import {ServiceHint, Services} from "./Container/Services";
import {Logger} from "log4js";
const { REST, Routes } = require('discord.js');
import {REST, Routes} from 'discord.js';
import {IconDeployer} from "./Icons/IconDeployer";
import {DiscordClient} from "./Discord/DiscordClient";
import {IconCache} from "./Icons/IconCache";
const container = Container.getInstance();
Services.setup(container, ServiceHint.Deploy)
const commands = new Commands().allCommands;
const environment = container.get<Environment>(Environment.name);
const logger = container.get<Logger>("logger");
// Construct and prepare an instance of the REST module
const rest = new REST().setToken(environment.discord.token);
const client = container.get<DiscordClient>(DiscordClient.name);
client.connectRESTClient(environment.discord.token)
const commands = client.Commands.allCommands;
// and deploy your commands!
(async () => {
@ -29,7 +36,7 @@ const rest = new REST().setToken(environment.discord.token);
logger.log(`Started refreshing ${commandInfos.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
const data = await client.RESTClient.put(
Routes.applicationGuildCommands(environment.discord.clientId, environment.discord.guildId),
{ body: commandInfos },
);
@ -43,4 +50,16 @@ const rest = new REST().setToken(environment.discord.token);
logger.log("Ensuring Database...");
const updater = new DatabaseUpdater(container.get<DatabaseConnection>(DatabaseConnection.name));
updater.ensureAvaliablity(Definitions);
updater.ensureAvaliablity(Definitions);
logger.log("Ensuring icons...");
(async () => {
const iconCache = container.get<IconCache>(IconCache.name);
await iconCache.populate();
const deployer = new IconDeployer(
iconCache
);
deployer.ensureExistance()
})()