Open source, automation and sharing with discord bots
Mohd Shamoon
May 26, 2022

When do you think a developer is the happiest?
For me it is when a piece of code written by you is used by someone and they are happy and thankful for it. That is the best feeling ever.



It is so fascinating to be in the technology space in today’s time. You can easily do, whatever you can think of today with all the tools and resources available on the internet. You just have to look for it in the right places and put in some time to understand it.


Early days

From my college days I have always wanted to solve a problem that was faced by many people and tried to look for it in the open source space. I found many problems but was not sure where to think and start. It was really difficult to pick someone else’s problem and think of a solution.

I looked at the various products that came into existence because of a problem the user wanted to solve in his life, and others liked it so they joined.

I decided that whatever problem I will face in my life maybe I can start with that and build a solution for myself. Finally I will make the code available publicly for anyone to use.


Problem

Sharing one of the problems that I faced recently while working on Glific

For this product we have a communication server on discord and we have many channels to communicate with the users and developers of the product. One of them is ngos-support, where our users ask for help, post questions or share issues with us.



Since there is a lot of messaging happening on that channel, sometimes we miss handling or checking on some of the issues as they have not been tracked anywhere.

We try to create issues on Github from there but it feels like a lot to move those messages into issues on a separate platform.


Solution

I saw a problem and worked on the best way to handle this.

I knew that discord provided some automations with the help of bots and tried to look for something that can help manage these missing issues.

First try
I started to look for something and came across a bot called tickets that can create a ticket based on a discord message https://ticketsbot.net/. It looked really cool as now we can create tickets and track them on discord only.



But somehow that did not work in our case as once the ticket is closed all the information and messages in that thread gets lost which was a concern for us.

So we decided to not go through with it.

Second try
I thought if we can directly open a Github issue from here how cool would that be.
So I started reading on how to create a discord bot that can connect with other services.

Discord has a comprehensive and great documentation. I was able to figure out how to interact with messages and capture events and now the next step would be to open an issue on Github through an API

Again thanks to comprehensive Github API and some good articles I was able to figure out how to create an issue through an API call

Final step would be to link all of this and try it out.

It took one full day just to experiment with it and make it somehow work.
Was really happy when it worked for the first time.



I shared it with my colleagues and they tried it out.
Looked good in the start. Let’s see how this will go in the future.


Sharing and open source

Since there was no other solution yet on the internet. I shared it on github for others to use and it seems like there are people like me who want this kind of solution.


Will work on it to improve this in the future for others to use.

Sharing some of the other problems that I faced and the solutions that I published on Github-

Auto close tab: I was really frustrated after opening so many chrome tabs at once and thought of a solution to automatically close them after a certain time of non usage.
This is the chrome extension that does that.

React d3 graphs: d3 is an awesome library for creating customized charts but there is a lot of configuration for it to use. I wanted to create a minimal react wrapper for some of the charts so these can be used easily. This package does exactly that.

Data studio visualization: Data studio has a predefined set of charts that we can use but there are limitations on styling and animations. Created a customized chart with Chart.js that can be imported in Data Studio to visualize data.

Bigquery discord bot: I wanted to display some stats data on a daily basis from bigquery to discord. For that I created this bot.

If these issues are faced by me I am sure that it will be faced by some more people and may this code help them to make some progress on their issues.

“And that is what open source is all about, getting from and giving back to the community😁.”