Files
discordeno/template/nodejs/index.js
Awesome Stickz b9766c6cb6 Update all templates' dd version, readme, added example env/config (#2500)
* Update bigbot template to v16, update readme, added .env.example for an example env

* Update minimal template to dd v16, update readme

* Update minimal template readme for consistency

* Update beginner template to v16, update readme

* Added config.json file, readme to nodejs template

* Fix kwik db stuff in beginner template

* deno fmt

* Update template readme

* Fix bigbot template raw event ignoring GUILD_CREATE instead of GUILD_LOADED_DD

* deno fmt

* fix deno fmt again

* Use .env file instead of config.json in nodejs template

* fix: kwik's version in beginner template

* Apply suggestions from code review

Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>

* Update template/README.md

Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
2022-10-07 16:41:11 -05:00

33 lines
1.0 KiB
JavaScript

require('dotenv').config();
const Discord = require("discordeno.js");
// Ideally you should switch this to .env but for a template a config json is enough
const config = require("./config.json");
const EventManager = require("./Managers/EventManager.js");
// looping through all events and registering them
const events = new EventManager({});
const baseBot = Discord.createBot({
events: events.load({}),
intents: Discord.Intents.Guilds | Discord.Intents.GuildMessages | Discord.Intents.MessageContent,
token: process.env.TOKEN,
});
const client = Discord.enableCachePlugin(baseBot, {});
client.config = config;
// looping through all commands and registering them in .cache of the class
const CommandManager = require("./Managers/CommandManager.js");
client.commands = new CommandManager(client);
client.commands.load({});
// Starts your Bot
Discord.startBot(client);
/*
* You should handle all errors and fix the issues in your codes...
* process.on('unhandledRejection', (reason, p) => {console.log(reason, p)})
*/