This is a fun purpose project made using nodejs with TypeScript. It uses the Discord.js library to connect with the discord api and interprete the given commands. Also, it consumes two external services to provide gif and news fetching!
- Dependency Injection
- S and D from SOLID
Currently, the bot only responds to these commands:
$gif searchTerm - which, of course, sends the fetched gif to the current channel
$news [--country] searchTerm - which fetches and retrives some links (max to 5) to headlines on news platforms
ps: the argumet --country should be replaced for a to etter representation of a country, such as us, br, uk and so forth. Besides, since it is optional, the default value is br, which fetch news on brazillian vehicles.
Connecting with external services is awesome, but it has it's trade-offs. If you check the .env.example file, you should find the necessary tokens to connect to those platforms. Make sure to get all of the listed keys and to create a .env file on the root dir to have access to the command functionalities.
-
DISCORDJS_BOT_TOKEN https://www.digitalocean.com/community/tutorials/how-to-build-a-discord-bot-with-node-js-pt
follow the configuration steps until you have a new bot on your server and its key
-
GIPHY_API TOKEN https://giphy.com/
-
NEWS_API_TOKEN https://newsapi.org/
Another quick note: this project uses dependency injenction to make it more flexible, so feel free to add your own providers
Besides, this project uses yarn as the dependency manager, so don't forget to install it.
To clone this project to your machine and download it's dependencies, you just have to run
git clone https://github.com/lucascprazeres/alfred
cd Alfred
yarn
Once you have done this and configured the environment variables as shown above, you're ready to go!
# As a user
yarn tsc #builds the typescript code into regular js
yarn start
#OR, as a dev
yarn dev # initialize the dev server
The bot should then begin to react to your $ prefixed commands.
Create your own branch on the project with
git checkout -b your-branch
Make your changes and send back to this repository
git add .
git commit -m 'tell me what have you done'
git push origin my-branch
Go back to the github repository page and create your pull request. I'll check it as soon as possible.
This project is under the MIT License. Consult the LICENSE file for further information.
If you liked the idea or it's implementation, don't forget to 🌟 this repository :)