<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: FlexICE</title>
    <description>The latest articles on DEV Community by FlexICE (@flexice).</description>
    <link>https://dev.to/flexice</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F895813%2Faaf149a5-2183-4baf-bb71-3ad3181081c3.png</url>
      <title>DEV Community: FlexICE</title>
      <link>https://dev.to/flexice</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/flexice"/>
    <language>en</language>
    <item>
      <title>IntellCreatio (Discord Bot Architecture)</title>
      <dc:creator>FlexICE</dc:creator>
      <pubDate>Fri, 30 Sep 2022 18:13:24 +0000</pubDate>
      <link>https://dev.to/flexice/intellcreatio-discord-bot-architecture-hm9</link>
      <guid>https://dev.to/flexice/intellcreatio-discord-bot-architecture-hm9</guid>
      <description>&lt;p&gt;Greetings to all who have decided to read this post, in which I will talk a little about the architecture that I began to write literally not long ago, and I am looking for like-minded people who would like to develop this project together!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What exactly is this?&lt;/strong&gt;&lt;br&gt;
This is an architecture that aims to simplify and more efficient development of discord bots based on the popular library &lt;a href="https://discord.js.org/#/" rel="noopener noreferrer"&gt;discord.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;br&gt;
Discord API in recent years is very advanced and grows more and more functional which is already becoming difficult to manage (I tell you as a person who made bots for popular Russian-language discord servers).&lt;/p&gt;

&lt;p&gt;It is not difficult to make a simple bot that writes something into a chat or mutilates and banishes participants if they have broken some certain rules.&lt;/p&gt;

&lt;p&gt;And what to do if you need a bot on a particular server that will be responsible for the economy, mini-games built around this economy, convenience for moderators in the form of bans and mutes on roles.&lt;/p&gt;

&lt;p&gt;When you start to talk about this unwittingly think that it is just as simple, but there is a problem that is very difficult to solve, over time, the code base grows surplus, or a set of utilities that could be put in separate packages or removed altogether, Working with the database, working over time - all this is very difficult.&lt;/p&gt;
&lt;h2&gt;
  
  
  What supports the architecture at the moment?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Environment Vars (.env)&lt;/li&gt;
&lt;li&gt;Database (TypeORM)&lt;/li&gt;
&lt;li&gt;Full TypeScript (ts-node)&lt;/li&gt;
&lt;li&gt;Flexible config file&lt;/li&gt;
&lt;li&gt;Hot Reload&lt;/li&gt;
&lt;li&gt;Interactions router&lt;/li&gt;
&lt;li&gt;Locales (i18n)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Interactions router&lt;/strong&gt;&lt;br&gt;
Instead of creating a script that will automatically load commands or context menus, I decided to make a better way to load certain scripts.&lt;/p&gt;

&lt;p&gt;There is a file called &lt;code&gt;interactions.json&lt;/code&gt; this file has full links to some scripts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"commands"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"example"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"~/interactions/commands/example.ts"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"user_context_menu"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"Log in Console"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"~/interactions/context_menus/example.ts"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"message_context_menu"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"buttons"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"delete"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"~/interactions/buttons/delete.ts"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"select_menus"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;~&lt;/code&gt; - This is the path to the project root directory.&lt;/p&gt;

&lt;p&gt;So our scripts can lie anywhere and we can turn them off at any time.&lt;/p&gt;

&lt;p&gt;Contribute to this project &amp;lt;3 (Please help me!)&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/intellcreatio" rel="noopener noreferrer"&gt;
        intellcreatio
      &lt;/a&gt; / &lt;a href="https://github.com/intellcreatio/intellcreatio" rel="noopener noreferrer"&gt;
        intellcreatio
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Architecture for Discord Bot
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;IntellCreatio&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;Architecture for Discord bot, for convenient operation.&lt;/p&gt;

&lt;p&gt;To configure the bot, you must refer to two files in this project, that is &lt;code&gt;config.ts&lt;/code&gt; and &lt;code&gt;.env.example&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.env.example&lt;/strong&gt; - rename file to &lt;code&gt;.env&lt;/code&gt; and configure the file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;config.ts&lt;/strong&gt; - This file is needed to fully configure the bot, you can also add those fields you want but be careful with those fields that already exist.&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Locales&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;Locales storage in folder &lt;code&gt;locales&lt;/code&gt; it's you can change in &lt;code&gt;src/consts.ts&lt;/code&gt; change value const &lt;code&gt;LOCALES_FOLDER_NAME&lt;/code&gt; to yourself&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Database configuration (TypeORM)&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;Locate in &lt;code&gt;database.config.ts&lt;/code&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Entities&lt;/h2&gt;

&lt;/div&gt;

&lt;p&gt;Located at the root of the project in the &lt;code&gt;entities&lt;/code&gt; folder, where you create models for the database and then connect these entities in &lt;code&gt;database.config.ts&lt;/code&gt;&lt;/p&gt;

&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/intellcreatio/intellcreatio" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


</description>
      <category>discord</category>
      <category>typescript</category>
      <category>discordjs</category>
      <category>node</category>
    </item>
  </channel>
</rss>
