generated from nhcarrigan/template
This commit is contained in:
+16
-1
@@ -6,6 +6,7 @@
|
||||
|
||||
import { Client, GatewayIntentBits, Events, Partials } from "discord.js";
|
||||
import { scheduleJob } from "node-schedule";
|
||||
import { App } from "octokit";
|
||||
import { handleMessageCreate } from "./events/handleMessageCreate.js";
|
||||
import { cacheData } from "./modules/cacheData.js";
|
||||
import {
|
||||
@@ -18,6 +19,19 @@ import { instantiateServer } from "./server/serve.js";
|
||||
import { logger } from "./utils/logger.js";
|
||||
import type { Amari } from "./interfaces/amari.js";
|
||||
|
||||
if (process.env.GH_CLIENT_ID === undefined
|
||||
|| process.env.GH_PRIVATE_KEY === undefined) {
|
||||
throw new Error("Cannot initialise GitHub!");
|
||||
}
|
||||
|
||||
const githubApp = new App({
|
||||
appId: process.env.GH_CLIENT_ID,
|
||||
privateKey: process.env.GH_PRIVATE_KEY.replaceAll("\\n", "\n"),
|
||||
});
|
||||
const octokit = await githubApp.getInstallationOctokit(83_119_105);
|
||||
const { data } = await octokit.rest.apps.getAuthenticated();
|
||||
await logger.log("debug", `Authenticated to GitHub as ${data?.name ?? "unknown"}`);
|
||||
|
||||
const amari: Amari = {
|
||||
discord: new Client({ intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
@@ -27,6 +41,7 @@ const amari: Amari = {
|
||||
GatewayIntentBits.DirectMessages,
|
||||
],
|
||||
partials: [ Partials.Channel ] }),
|
||||
github: octokit,
|
||||
lastRssItems: {
|
||||
freeCodeCamp: null,
|
||||
hackerNews: null,
|
||||
@@ -66,4 +81,4 @@ amari.discord.on(Events.UserUpdate, (_oldUser, updatedUser) => {
|
||||
});
|
||||
|
||||
await amari.discord.login(process.env.BOT_TOKEN);
|
||||
instantiateServer();
|
||||
instantiateServer(amari);
|
||||
|
||||
Reference in New Issue
Block a user