Freecodecamp: Create a new Camperbot for the official discord server

Created on 2 May 2020  Â·  29Comments  Â·  Source: freeCodeCamp/freeCodeCamp

Is your feature request related to a problem? Please describe.
FreeCodeCamp recently created an official discord server (here is the announcement), and a few members would like to have a new version of the gitter bot (camperbot) that was featured on the gitter chat.

Describe the solution you'd like
A new camperbot can provide some of the original's functionality such as giving brownie points when thanking other users, and potentially provide other features directly related to freeCodeCamp's current curriculum and platform, such as including codeRadio, or linking to guides/challenges. If anything there are some discord patterns where the server's bot helps protect against spam by forcing user's to read the rules (in this case, FCC's code of conduct) before gaining access to all the channels.

Describe alternatives you've considered
We don't need a discord bot, especially if the reasoning behind the original gitter bot decline/deprecation still applies.

Additional context
Some relevant related issues and links I've found in the forum related to the development and maintenance of the gitter bot that should still apply to the discord version.

edit
Features so far suggested, in no particular order:

  • Give "brownie points" for thanking users (primary feature from gitter-bot version) This will not be added, due to the original's issue with spam and "gaming" the system for thanks.
  • Automated welcome message(s) for new users

    • Connect this to the code of conduct

  • Leveling mechanic, connected to some "currency" to buy new levels

edit 2
I created a post in the forums* to discuss future and post features. This issue will stay open for now, but the main discussion should be done on the forums for now. We can probably close this issue once we can reference another repo/issue for the bot so anyone finding this in the future doesn't "get lost" outside of github on the forums :)

feature request

Most helpful comment

@bradtaniguchi I only referenced the mee6 bot to give an example of a level system. There's a lot in the mee6 bot that I've never used. I just like the levels.
@drv-rajesh Automated moderation is concerning. In my experience, bots were always too heavy handed with the kicks/bans.

All 29 comments

It'd be a nice feature to add Camperbot. But as I don't know the reasoning behind the deprecation, I'll leave it to the maintainers ;)

I'd be interested in this. Any preference regarding the programming language? The old one was in JavaScript, so could be used for inspiration if the new one shall be in JavaScript as well.

Where would it be hosted?

I'd be interested in this. Any preference regarding the programming language? The old one was in JavaScript, so could be used for inspiration if the new one shall be in JavaScript as well.

Where would it be hosted?

I'd prefer for this to be hosting in a place that is "as close" to the actual FCC stack as possible, or at least following the original gitter bots hosting provider. There is always the issue of cost for hosting this app, so unless FCC is able to front the costs, the hosting will have to be done super cheaply or managed by other people.
I'm not sure what the original gitter bot ran on or cost to run, but its original costs and features should give us an indication as to how much it would cost to manage this one.

I personally would want TypeScript, but just JS would be fine as the feature set for this bot wont be super crazy or anything.

@bradtaniguchi Thanks for opening this issue.

I'm also in favor of creating a new Discord bot based on our Gitter bot. We should discuss the specific user stories we want to prioritize, and use that as a starting point. Could we all list the specific functionality we want for such a bot? Then Brad could organize these user stories and list them out.

@QuincyLarson I've seen a couple of people in the discord server request automated welcome messages.

Personally, I'm a fan of experience point features, where users gain "levels" based on the degree of interaction.

@nhcarrigan an extension of that idea would be to integrate all the features of a professional bot (i.e. welcome, levels, etc.). We could call this a custom FCC bot and users can buy certain roles using levels. I have seen examples of this in other servers.

@drv-rajesh Could you record a quick screen share where you demo this functionality within another Discord? This would be helpful to give everyone here on this issue thread a better understanding of how this would work.

image
@QuincyLarson Here's a screenshot of the leveling functionality from another discord bot, if this is what you were looking for.

image

This is another example @QuincyLarson. You advanced levels in the server by chatting and each time you get a higher level, it DMs you. There is also a currency feature in the server that each time you advance a level, you get more money.

The MEE6 bot has a lot of features we probably don't want or need. It also is a "freemium" bot in that there are paid for levels.
Here's the site for the bot: https://mee6.xyz/

Out of the advertised features the bot provides only the automated troll/spam prevention looks to be worth wild. So far the discord server has been pretty tame, as was the gitter room (which didn't have a bot). (here is an issue around having the original gitter bot ban user's) So it isn't a "killer" feature.

The original gitter bot used to update a user's "grid" profile when given brownie points, this might be more relevant to FCC's discord bot then ranks.

Overall the MEE6 both would be nice to inspire too, but if we are to create our own bot it can have its own features that are relevant to FCC's community.


So far the features mentioned are the following (I'll add these to the original post aswell), in no particular order:

  • Give "brownie points" for thanking users (primary feature from gitter-bot version)
  • Automated welcome message(s) for new users

    • Connect this to the code of conduct

  • Leveling mechanic, connected to some "currency" to buy new levels

@bradtaniguchi another feature the bot could potentially contain is automated moderation based on criteria such as:

  • Swearing
  • Inappropriate use of channels

Also, will the team that is working on the bot be working on each different component of the bot, or how is the collaboration going to work?

@bradtaniguchi I only referenced the mee6 bot to give an example of a level system. There's a lot in the mee6 bot that I've never used. I just like the levels.
@drv-rajesh Automated moderation is concerning. In my experience, bots were always too heavy handed with the kicks/bans.

@bradtaniguchi another feature the bot could potentially contain is automated moderation based on criteria such as:

  • Swearing
  • Inappropriate use of channels

Also, will the team that is working on the bot be working on each different component of the bot, or how is the collaboration going to work?

Yea I agree with @nhcarrigan, automated moderation should be light. On the forums there are some tools to prevent spam, bad words. Even the previous gitter chat didn't have any of these features and was fine (it didn't have any AFAIK)

I'm not too sure how the team collab will work. I would believe setting up the initial version, and handling deployments and maintenance to keep it running to be the most important initially regardless of features. In that regard we should get as much input from current maintainers of the rest of the FCC stack.

The features themselves could be tackled by individuals all working on different issues, but the core "bot" development needs to be stamped out first before anything could start.

I have quite some experience with the Discord API, mainly discord.py(which is a python library for the API) I will not give ideas regarding what the bot should do, since other people have already given bright ideas, but I can give tips regarding the actual program.

If you ask me, I will recommend to write the bot in Python which is just a arbitrary choice but it also has some advantages over the other libraries written for other languages like discord.js.
Most of the examples given below will be for discord.py or just Python.

Whenever I make any Discord bots, I store all the data in a JSON file:
image
I also write a program which makes manipulating the JSON file much easier using the Python property decorators and an additional module called scapl(Makes it easier to manipulate nested dictionaries)

When writing the program, it gets quite messy, so there is a class in discord.py, cogs. Using cogs, the full program can be splitted into multiple files, which can each contain certain commands pertaining to it's category. Also, I am expecting the program to be made using commands(it is like a sub-library of discord.py which is used to make commands appropriately) or I reckon I will be quite disappointed since the other option is to use a on_message event which is not the recommended way.

Additionally, There are some few minor things I also recommend using:

  • Logging deleted messages. Although there is a flaw, you cannot access as to who deleted the message but only who's message got deleted:
    image
    image

  • Output errors to a channel, which makes debugging easier:
    image
    image

  • Log whenever a moderator or administrator uses high-level commands like mute, kick, ban et al.
    image

  • Lastly, this is how the greeting/farewell mechanism can work:
    image

(I also use the official reference, because I don't remember what is where.)

@Esfectus This is all very impressive and I support it!

Now that we've _somewhat_ nailed the feature set we want, I think it's a good time to talk about the implementation details.

Here's some implementation details we need to think about (+ a little bit of my rambling) -

  1. What language to use?

As far as I know, the majority of the FCC's codebase, both front and backend is written in JS.
(FCC's learning platform, FCC's forum etc.) So, if we want a deep integration with the current codebase, JS would have a head start.

Also to note, the FCC's sites and APIs are also written in JS (ngix) and is handled mostly by _the legendary_ Mruggesh. If the bot is deployed, he'll probably be deploying it and by now he's quite comfortable with the JS stack....so sticking with JS will make his life a little bit simpler. If the bot is implemented in JS, I think it'd be a huge advantage at least when it comes to deploying.

The bot, I am _guessing_, will also need a DB. Since MongoDB is being used by FCC for the majority of its sites and APIs, I think it has an advantage here too.

So, all in all, I think JS would be the favourite cause FCC's using JS heavily.

  1. Where to deploy?

I'll leave this to the more experienced devs.....

  1. Which library to use (_if any_)?

I loaded up the repos for the most popular Discord libraries in Github for both JS and Python.

For JS, it's discord.js and for Python it's discord.py. Here's a comparison of the two repos -

discord.js (_JS_) | discord.py (_Python_)
------------ | -------------
4,709 commits | 2,315 commits
234 contributors | 155 contributors
24 open PRs | 44 open PRs
44 releases | 54 releases
54 issues | 113 issues
License: Apache-2.0 | License: MIT

Another thing I almost forgot to mention is that, the previous bot was written in JS....which can be a stepping stone for the new bot. (Credit goes to @Ryuno-Ki as he figured that out)

What about using some ideas of discord.py and port them to discord.js? (Or TypeScript, if you insist)
Like, structuring the code in a similiar way?

I'm familiar with both/all three languages.

What about using some ideas of discord.py and port them to discord.js? (Or TypeScript, if you insist)
Like, structuring the code in a similiar way?

I'm familiar with both/all three languages.

Same for me. I do not have a preference on which language to use, but after reading @Twaha-Rahman's views, I think that JS is the better option, or Java integration in Python using Jython.

What about using some ideas of discord.py and port them to discord.js? (Or TypeScript, if you insist)

I do prefer TypeScript as it it is much harder to screw-up your code, improves debugging and VSCode turns into an unicorn when it sees TS. But, if we want to be as close to the FCC codebase vanilla JS seems to me the way to go. Unless of course, everybody agrees to use TS 😉

I was recommending discord.py mostly on a personal whim, but now I have done some research and discord.js is the better option here just like @Twaha-Rahman said. And if I am not wrong, it has more features than discord.py, so I would also go with discord.js but just in case, I will list all the arsenal of options.

  1. discord.net
  2. discord4j
  3. JDA
  4. discordie
  5. discord.io
  6. eris
  7. restcord
  8. discordrb
    Apparently, there are a lot of modules for JavaScript.

If we decide to use TS to stray away from the vanilla JS that the original Gitter bot was written in, then discord.ts is the library that handles connection with the API, written completely in TS for easier usage; however as TS is a syntactical super-set of JS then we can port the modules @Esfectus mentioned into TS.

Apparently, there are a lot of modules for JavaScript.

It's JavaScript! Days without a new framework, you know?

Back to topic: TypeSearch had 0 results for the libraries listed by Esfectus, i.e. we would have to come up with our own.

So TypeScript then?

Two more questions to answer …

There are hundreds of unofficial libraries for the Discord API, I just stated the popular ones. @Ryuno-Ki

My understanding is the official nodejs lib discord.js supports TypeScript out of the box.
I like TS, but sticking to JS and staying as close to the FCC stack as possible should be paramount. Last thing we want is to make things different, then not be able to maintain it and the bot breaks down the line with no one to fix it.

After doing some quick checks on the original gitter bot, original didn't access any database directly, rather it made api calls to the main back end of the FCC stack. This kept access to the database to a minimum.

I personally like to handle logging by the service provider, but this really depends on the hosting provider and environment. I think the idea to log to a channel might be nice, but also might be ugly and worse off then a traditional logging solution.


I think its time we ask for some help on figuring out the deployment stack, and overall architecture for FCC as it seems we are all out of our element so far :) (I'll be reaching out to some of the FCC team members on gitter's contributor channel, as thats the documented place to ask for help it seems)

Where would it be hosted?

I'd prefer for this to be hosting in a place that is "as close" to the actual FCC stack as possible, or at least following the original gitter bots hosting provider. There is always the issue of cost for hosting this app, so unless FCC is able to front the costs, the hosting will have to be done super cheaply or managed by other people.
I'm not sure what the original gitter bot ran on or cost to run, but its original costs and features should give us an indication as to how much it would cost to manage this one.

I got a small server on Digital Ocean for my own bot, and it works perfect. I've seen people host on a free Heroku too, but with downtime.
If you want, maybe I could give access to part of my server for testing the new bot?

I got a small server on Digital Ocean for my own bot, and it works perfect. I've seen people host on a free Heroku too, but with downtime.
If you want, maybe I could give access to part of my server for testing the new bot?

I was told that the FCC team will manage the devops of the bot, so they will handle it. Thank you for the offer though :)

Was this page helpful?
0 / 5 - 0 ratings