Blog Post Cover

Introduction to Discord Bots

Introducing Angra - the Javascript NPM library that simplifies the process of composing and sending transactional emails. With Angra, developers can easily send emails such as registration confirmations, verification codes, and order confirmations without having to write any additional code. The library is available for installation via npm or yarn, and once installed, users simply need to provide their SMTP credentials for the library to take care of the rest. This means that developers no longer have to spend time writing and testing email-sending code, and can instead focus on building the core functionality of their application. One of the key features of Angra is its ease of use. With just a few lines of code, developers can send an email with a custom template and variables.

Innovative use cases for Discord bots are constantly being developed, and the possibilities are endless. Some examples include: Language bots that can translate text from one language to another. Virtual assistants that can help users schedule appointments, set reminders, and more. Bots that can help users with mental health and self-care, such as providing meditation exercises or journal prompts. Bots that can help users learn new languages, by providing practice exercises and flashcards. Bots that can help users with their finances, by providing budgeting tools and investment advice. In conclusion, Discord bots are powerful tools that can enhance the user experience on the platform in many ways, from playing music and games to providing useful information and tools. As developers continue to create new and innovative bots, the possibilities for how they can be used are endless. Whether you're a server administrator, a gamer, or just someone looking for a way to enhance your Discord experience, there's likely a bot out there that can help. / accretence / andia

Discord v14 bot with parallel Express.js Server, built with Typescript and Prisma

Setting up a Discord V14 Typescript Bot

Setting up a TypeScript Discord bot involves several steps: First, you will need to create a new Discord bot. You can do this by visiting the Discord Developer Portal and creating a new application. Once your application is created, navigate to the "Bot" section and create a new bot. You will then be presented with a token, which you will use to authenticate your bot with the Discord API. Next, you will need to install Node.js and npm (Node Package Manager) on your computer. These can be downloaded from the official Node.js website. After Node.js and npm are installed, you can create a new directory for your bot and navigate to it in your terminal. Run the command npm initto initialize a new npm project, and follow the prompts to set up your package.json file. Now, you will need to install the necessary packages for your bot. These include the Discord.js library, which allows you to interact with the Discord API, and the TypeScript compiler. You can install these packages by running the following commands in your terminal:

npm install --save discord.js
npm install --save-dev typescript
Once the packages are installed, you will need to set up your TypeScript configuration file. This file, calledtsconfig.json, tells the TypeScript compiler how to build your project. You can create this file by running the command tsc --init in your terminal. In your tsconfig.json file, you will need to set the "target" to "es6" and the "module" to "commonjs". This will ensure that your code is transpiled to the correct version of JavaScript for Node.js. Now, you can create a new file called "index.ts" in your project directory. This will be the main file for your bot. In this file, you will need to import the necessary modules from the Discord.js library, as well as any other modules you may need for your bot. To authenticate your bot with the Discord API, you will need to use the token you obtained from the Discord Developer Portal in step 1. You can do this by passing the token to theclient.login() method, like so:
Next, you can set up event handlers for your bot. These event handlers will be called when certain events occur, such as when a user sends a message or when a user joins a voice channel. Finally, you can write the logic for your bot in the event handlers. This can include commands that users can run, as well as any other functionality you want your bot to have. To start the bot, run tsc and then node dist/index.js in the terminal, this will transpile your typescript code to javascript and execute it with node.js You can test your bot by inviting it to a Discord server and interacting with it in the server. Note that this is just a basic tutorial and there are many more things you can do with a Discord bot written in TypeScript, like using a framework or using decorators for better handling events and commands.