Creating a discord auto threading system

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

In case you missed it, I launched a discord server for technical writers: Technical Types Community.
The idea of this server is to create a dedicated space for technical writers, where we can collaborate, share ideas and ask questions.
This is an open-sourced free for all and welcoming community.
I introduced a channel to get feedback on your work with this community. However, the realization quickly was that feedback gets buried if there are a lot of comments.
Threads would be a fantastic solution. However, it's difficult to force and monitor this behavior.
That leaves us with only one choice: Automate it!

The first thing we need to take care of is to make sure people can only post one link per x hours.
Luckily for us, discord comes with this feature built-in, and it's called "slow mode" this allows a user to only post once per x hours on the main thread.
This is no longer applicable in the threads created, so ideal for what we want to achieve.
To enable slow mode for a channel, click the little gear icon next to the channel's name.

Then you want to set the slow mode slider to the max (6 hours).

This setting will make sure a user can only send one message per 6 hours on the main channel.
We want to make sure a thread is created for every post on this channel.
We won't be building this bot from scratch as a super awesome one already exists.
It's this Discord needle bot.
However, I did make my own version of this because I wanted it to work with .env variables.
Markus made some changes to his one based on my feedback, and you can use his custom-config branched version at the point of writing this.
If you choose to use my version, you must create a .env file that includes the following two variables.
API_TOKEN={DISCORD_API_TOKEN}
CHANNEL={CHANNEL_ID}
To find the discord channel id, you will need to enable developer mode in discord.
Click your user profile settings by clicking on the gear icon next to your profile.

Then you can find the "Advanced" menu and toggle the developer mode on.

Once this is on, you can right-click any channel and click the "Copy ID" option.

We have to create the discord bot by visiting the Discord Developer portal.
Create a new bot by clicking the "New Application" button.
Once you've done this, click the "Oauth2" item. Select "Bot" as the scope and check the following permissions.

Click the copy button at the bottom and paste this into a new tab. This will prompt a setup for this bot. Select the server you want to add this bot to.

Now it's time to run your bot.
To test the bot, you can run the local version using npm start in the project.
Or you can follow my guide on running a bot on Railway app.
You should now post on this channel, and a thread will be automatically created for you!

Or even better, you can try it in real life on the Technical Typers Discord server
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter