first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
const path = require("path");
|
||||
const dotenv = require("dotenv");
|
||||
|
||||
const { createBotClient, sendQuoteForUser, wireQuoteCommandHandlers } = require("./src/bot");
|
||||
const { createWebServer } = require("./src/web");
|
||||
const { loadAppConfig } = require("./src/config");
|
||||
|
||||
dotenv.config();
|
||||
|
||||
async function main() {
|
||||
const configPath = process.env.QUOTE_CONFIG_PATH || path.join(__dirname, "config", "quotes.config.json");
|
||||
const appConfig = loadAppConfig(configPath);
|
||||
|
||||
const client = createBotClient();
|
||||
wireQuoteCommandHandlers(client, appConfig);
|
||||
|
||||
client.once("ready", () => {
|
||||
console.log(`Discord bot connected as ${client.user.tag}`);
|
||||
});
|
||||
|
||||
await client.login(process.env.DISCORD_TOKEN);
|
||||
|
||||
const port = Number(process.env.PORT || 3000);
|
||||
const app = createWebServer({
|
||||
users: appConfig.users,
|
||||
allowedSubmitterDiscordIds: appConfig.allowedSubmitterDiscordIds,
|
||||
onQuoteSubmit: ({ userId, quoteText, creator, attachmentUrl }) =>
|
||||
sendQuoteForUser(client, appConfig, userId, quoteText, creator, "website", attachmentUrl),
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Web form available at http://localhost:${port}`);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("Failed to start application:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user