Ever wanted to make a Discord bot, but don't want to learn how to code? Tired of having AI generate all your code? Then Bloccord is for you!
Built for BCIT's HackTheBreak 2026, this project combines React, React Flow, TypeScript, ts-morph, and Discord.ts to streamline your bot creation using simple blocks.
This project was made with 2 members in CST Term 3.
Bloccord makes bot creation simple, easy to read, and great for beginning coders. Users can make their scripts using a user-friendly block coding interface, and download their code in just a few easy clicks.
When building a Discord bot, we noticed a lot of boilerplate code was duplicated everytime you wanted to make a new function. We were inspired by Scratch and Unreal Engines' simple interfaces to make Discord bot creation as simple, yet powerful, as possible.
Our app allows users to build Discord app commands using blocks. Once a user is finished creating all their commands, they can simply click Download, import the files into their Discord.ts project, and they're done. Users can also preview their code before downloading in case they find any mistakes.
We used React Flow for the visual canvas and TypeScript for type safety. Our node system uses OOP every node type extends an abstract BaseNode class that enforces a generateCode() contract. A Factory pattern converts the visual nodes into class instances, and a Singleton CodeGenerator manages an inmemory file system using ts-morph(ts-morph to programmatically generate TypeScript files). This means adding a new node type requires zero changes to the code generation just create the class and register it in the factory. All this makes it super easy to create more nodes.
- The bot code could not be downloaded before being zipped. This was fixed by saving all the project files into memory and zipping them up from there.
- Discord only allows one interaction.reply() per command, so chaining multiple ActionNodes would crash the bot. We solved this by having CodeGenerator detect the first action vs subsequent actions and generate reply vs followUp accordingly.
- We also struggled with closing braces inside of conditions. ConditionNode generates an opening curly brace in the if statement, but we had to figure out where to close it. We decided CodeGenerator owns the structure, so it simply references the left and right nodes of it.
- For nodes to stay abstract, each different kind of node takes a different class.
- We initially had too much coupling in our code, so we started coding more abstract and making sure nothing depended on each other allowing us to easily create more features. This is when we started properly using OOP principles.
- Slash commands cannot be uppercase, so all uppercase commands are put into lowercase before being translated into code
- Slash commands cannot be empty, so any command that is empty is changed into 'Default'
- A command must have a reply, so a default message is generated if no replies are in the code
We made a fully functioning system to translate blocks into usable TypeScript code while following OOP principles. Neither of us were very familiar with React, and we managed to pull off a system that is both functional and aesthetically pleasing. The system came out exactly as planned, and has very few limitations. The system is also modular, which makes it incredibly easy to add more features later down the road.
We learned how to use TypeScript with React. We learned about using React Flow to create user-friendly diagrams. We also learned how to dynamically create code files with ts-morph.
We want to add more kinds of blocks to the user interface, such as message listeners, emoji reactions, loops, variables, and more. We would also like to make the bot runnable from the web browser to make setup even easier for the end-user. It would also be great if we could make the bot exportable to more than just TypeScript, such as Python or Java.
These steps will guide you through your bot creation journey. These steps should work on any modern system, as long as you have all the prerequisites.
- Node.js
- A free Discord account
- A modern web browser, such as Firefox or Google Chrome
- A text editor, such as Notepad or TextEditor
- Basic command line knowledge
- Navigate to the Discord Developer Portal
- Click on New Application
- Enter a bot name in the space provided, agree to the terms of service, and click Create

- Click Bot on the left pane
- Click Reset Token, and note the token for use in a later step. This may prompt you to re-enter your Discord password; do so.
- Scroll down to 'Privileged Gateway Intents' and enable 'Message Content Intent'

- Navigate to Installation using the left pane
- Uncheck User Install
- Scroll down to 'Default Install Settings'
- Inside of 'Scopes', add 'bot'
- Inside of 'Persmissions', add the permissions for your bot, such as 'Send Messages.' Alternatively, add the 'Administrator' permission to allow your bot to do anything on your server. However, this could be dangerous as the bot could do anything on your server.
- Navigate to the Install Link provided to you above 'Default Install Settings'

- Choose a server to add your bot to, then click Continue
- Make sure your required permissions are selected, then click Authorize. If you do not see your permissions, close the tab and go back to step 11.
- If you've done everything correctly, you should see your new bot join your Discord server.
- Navigate to a memorable folder, such as Documents
- Open a terminal in the folder
- In the terminal, run
npx create-discordx - Enter a project name, or leave blank to name it 'my-bot'
- Pick 'npm' as your package manager by using your arrow keys to navigate and 'Enter' or 'Return' to select.
- Choose the 'blank' template, and wait for everything to download. Once finished, you should see something similar to the following image

- Navigate the terminal to inside the project folder, which is named whatever you called it in step 4
- Run
npm i dotenv - Create a new file called .env
- Inside the file, add a line with the content
BOT_TOKEN="YOUR BOT TOKEN", ensuring you replace the content with the bot token you got in the first part
- Delete all contents of the src folder
- You are now ready to move on to the next step
There is a video showing how to create a basic command here. Alternatively, follow the text instructions below.
- Navigate to Bloccord
- Note the website layout

- Create a new slash command by creating a new Event trigger block
- Enter the command name in the block's input. Note that you do NOT put in the / at the start
- Add a response by creating a new Action block
- Enter the response content in the block's input
- Connect the bottom handle of the Event Trigger to the top of the Action block to execute the code once the command is entered. The end result should look like the following

- Congratulations, you've made your first slash command!
- Once you've finished developing commands, click Save project to download the code as a .zip file
- Extract the contents of the .zip file into the src file in your Discord project folder.
- Inside the src/main.ts file, either replace the guild ID in
botGuildswith your bot's guild id (find out how to do that here), or remove the line entirely. Note that removing the line will make slash commands register much slower.
!! Note: you do NOT have to replace your main.ts everytime you import code, just the first time you run !!
- Inside of the Discord project folder, open a terminal
- Run
npm run devin the terminal - Your bot should now be online, test it out!

!! Note: sometimes new commands can take 5-10 minutes to register, this is normal !!
- When running
npx create-discordx, it's giving an error that the command is not found- Ensure you have Node.js, and that it's on your system PATH.
- I get an error running the bot that dotenv / BOT_TOKEN is not found
- Run
npm i dotenvinside the Discord project folder, and make sure you have a .env file with your bot token inside in the format ofBOT_TOKEN="REPLACE WITH YOUR TOKEN"
- Run
- My old slash commands are still registered
-
Just above
await importx(\`${dirname(import.meta.url)}/{events,commands}/**/*.{ts,js}\`);add these lines:await bot.clearApplicationCommands( ...bot.guilds.cache.map((g) => g.id) );
-