Adds initial progress
This commit is contained in:
commit
a0b668cb90
34 changed files with 2680 additions and 0 deletions
46
source/deploy.ts
Normal file
46
source/deploy.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import Commands from "./Discord/Commands/Commands";
|
||||
import {Environment} from "./Environment";
|
||||
import {DatabaseConnection} from "./Database/DatabaseConnection";
|
||||
import {DatabaseUpdater} from "./Database/DatabaseUpdater";
|
||||
import Definitions from "./Database/definitions";
|
||||
import {Container} from "./Container/Container";
|
||||
import {ServiceHint, Services} from "./Container/Services";
|
||||
import {Logger} from "log4js";
|
||||
|
||||
const { REST, Routes } = require('discord.js');
|
||||
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);
|
||||
|
||||
// and deploy your commands!
|
||||
(async () => {
|
||||
try {
|
||||
const commandInfos = [];
|
||||
commands.forEach((command) => {
|
||||
commandInfos.push(command.definition().toJSON())
|
||||
})
|
||||
|
||||
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(
|
||||
Routes.applicationGuildCommands(environment.discord.clientId, environment.discord.guildId),
|
||||
{ body: commandInfos },
|
||||
);
|
||||
|
||||
logger.log(`Successfully reloaded ${commandInfos.length} application (/) commands.`);
|
||||
} catch (error) {
|
||||
// And of course, make sure you catch and log any errors!
|
||||
logger.error(error);
|
||||
}
|
||||
})();
|
||||
|
||||
logger.log("Ensuring Database...");
|
||||
const updater = new DatabaseUpdater(container.get<DatabaseConnection>(DatabaseConnection.name));
|
||||
updater.ensureAvaliablity(Definitions);
|
||||
Loading…
Add table
Add a link
Reference in a new issue