82 lines
2.6 KiB
TypeScript
82 lines
2.6 KiB
TypeScript
import 'dotenv/config'
|
|
// import loadCommands from './loadCommands.js'
|
|
// import deployCommands from './deployCommands.js'
|
|
// import loadEvents from './loadEvents.js'
|
|
// import updateDiscordMessage from './tasks/update_discord_message.js'
|
|
import { type WorkerUtils } from 'graphile-worker'
|
|
import { bot } from './bot.ts'
|
|
import type { Interaction } from '@discordeno/bot'
|
|
import { importDirectory } from './utils/loader.ts'
|
|
import { join, dirname } from 'node:path'
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
|
export interface ExecuteArguments {
|
|
interaction: Interaction;
|
|
workerUtils: WorkerUtils;
|
|
}
|
|
|
|
if (!process.env.AUTOMATION_USER_JWT) throw new Error(`AUTOMATION_USER_JWT was missing from env`);
|
|
if (!process.env.DISCORD_TOKEN) throw new Error("DISCORD_TOKEN was missing from env");
|
|
if (!process.env.DISCORD_CHANNEL_ID) throw new Error("DISCORD_CHANNEL_ID was missing from env");
|
|
if (!process.env.DISCORD_GUILD_ID) throw new Error("DISCORD_GUILD_ID was missing from env");
|
|
if (!process.env.WORKER_CONNECTION_STRING) throw new Error("WORKER_CONNECTION_STRING was missing from env");
|
|
|
|
const preset: GraphileConfig.Preset = {
|
|
worker: {
|
|
connectionString: process.env.WORKER_CONNECTION_STRING,
|
|
concurrentJobs: 3,
|
|
fileExtensions: [".js", ".ts"]
|
|
},
|
|
};
|
|
|
|
// async function setupGraphileWorker() {
|
|
// const runnerOptions: RunnerOptions = {
|
|
// preset,
|
|
// taskList: {
|
|
// 'updateDiscordMessage': updateDiscordMessage
|
|
// }
|
|
// }
|
|
|
|
// const runner = await run(runnerOptions)
|
|
// if (!runner) throw new Error('failed to initialize graphile worker');
|
|
// await runner.promise
|
|
// }
|
|
|
|
|
|
// async function setupWorkerUtils() {
|
|
// const workerUtils = await makeWorkerUtils({
|
|
// preset
|
|
// });
|
|
// await workerUtils.migrate()
|
|
// return workerUtils
|
|
// }
|
|
|
|
async function main() {
|
|
|
|
bot.logger.info('Starting @futureporn/bot.')
|
|
|
|
bot.logger.info('Loading commands...')
|
|
await importDirectory(join(__dirname, './commands'))
|
|
|
|
bot.logger.info('Loading events...')
|
|
await importDirectory(join(__dirname, './events'))
|
|
|
|
|
|
// const commands = await loadCommands()
|
|
// if (!commands) throw new Error('there were no commands available to be loaded.');
|
|
// await deployCommands(commands.map((c) => c.data.toJSON()))
|
|
// console.log(`${commands.length} commands deployed: ${commands.map((c) => c.data.name).join(', ')}`)
|
|
// const workerUtils = await setupWorkerUtils()
|
|
// setupGraphileWorker()
|
|
await bot.start()
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error("error during main() function")
|
|
console.error(e)
|
|
process.exit(3)
|
|
})
|