From the course: Build with AI: Developing a Discord Bot Conversationally

Course introduction

- [Instructor] Welcome to the course Build with AI, Developing a Discord Bot Conversationally. We're gonna talk about how to build zero code, full feature production ready bots. Okay, let's go ahead and get started here and take a look at how a traditional Discord bot would be developed. The barriers to entry would be you have to learn Discord.JS API, Node itself is a big ask because of the complexity of the packaging system. You have to write a lot of boilerplate code, debug syntax, deploy the infrastructure, maybe it will take you two weeks. Some of the common failures could include syntax errors, API misunderstanding, permission issues, hosting, maintenance burden. Maybe a lot of people would get started, but maybe the majority, let's say 90% would get started and then abandon the project. With a conversational style development, you can describe what you want in plain English and the AI would generate the complete implementation. Now, we should clarify here that the devil is in the details and that one of the really important things to do when you're using this style is to write a roadmap where the roadmap has all of the things that are necessary. So this would be the thing you would want to ask is build a roadmap and have a ticket for every single action that you'll perform, and then also test immediately in Discord and then refine through a conversation and then deploy with one command. Now, what you're gonna build in this particular course is a welcome bot, commands, moderation, databases, production, and some of the things we'll cover would be the foundation, the features, the advanced things that you can do, how to debug it, and also how to deploy it. Something I call the CODER loop in this style of development is this converse. So describe what you want. And again, a roadmap with very specific details is something you'd wanna say to the agents you'd have, you have to say, look, I wanna build a roadmap and I want you to explicitly give me the tickets. You wanna observe what's being generated, so you do need to understand what's happening, clarify things, ask it to run tests, debug it. So when you identify something, stop, that there's a problem. Ask for maybe five whys, ask why this is actually happening, and then enhance when you want to make another features. Again, what I would say is put this into the roadmap and then repeat. And so you iterate and iterate and iterate. And if you have a build system that's constantly testing your code as well, like GitHub actions, it's going to have this CODER loop be successful. In terms of an AI development stack, some of the things that you could use would be Claude Opus four one inside of Claude Code. This is pretty good at logic and debugging and production patterns. You can have agents as well run in the background, like for example, PMA could look at complexity or look at self admitted technical debt where you're developing and even rewrite some of your code for you with Opus. Bedrock is another thing that is very helpful in developing, because you can talk to multiple models. You also have API integration, and then other tools. For example, like a coding assistance like GitHub co-pilot could give you completions. One of the ways that you could develop a bot in a few minutes is you could write the prompt, hey, create a Discord bot that says hello when it comes online, and it would generate, let's say, a package.json with dependencies, the index.js file, et cetera. Now, one of the ways that could really become a problem though is if there is some kind of an issue with this, because it's a scripting language you potentially could get into, it took five minutes for it to kind of work, but then another five days for you to debug it. And this is where things like Rust really come into play because if you have, for example, the universal bot that we'll talk about later, you could actually just extend it versus building your own, because Rust is such a solid language. Now, what would be the real conversation flow? You could say, hey, I want you to add a ping command that shows the latency, right? And then the AI would generate a slash command, or I want you to make it show in an embed with color. And then this would update with Discord embed or add a timestamp and server and then enhance with requests. So you even can deploy the bot into, let's say, Discord. And then you could have it develop things, for example, conversationally, right? So as you're going through and you're building these different commands and you help and info, you also could be interacting with it and further developing the system at the same time you're using it. You could have different buttons or menus, and you could say, look, I want you to add a help command that lists all the commands in different categories. The event listeners would go through natural language, so you could even start to talk to it, because again, you have the ability to translate natural language. When someone joins, send a welcome message. If a message contains banned words, delete it. When someone gets a role, log it. React to messages through thanks, track voice channel activity, et cetera, et cetera. And in terms of rich embeds by description, you could do a basic embed, and this would be creating an information embed with a title and a description. You can enhance things with fields and footers and timestamps. You could add buttons like a yes or no. You could say, look, make a welcome embed with user avatar as thumbnail, sever name and title, member count, and footer, green color. So what's really important here is that you have to be very careful about what you described, and then also you should inspect it to make sure that it built what you wanted. If not, you may have to do several iterations. In terms of a database without SQL, this is another way to think about things, is that you could learn SQL syntax, set up a database, write queries, handle queries. So for example, you could say, I'd like you to set up a SQL light MongoDB, and also I want you to create a schema and implement CRD operations and handle the errors. Now, this is best done in something like Docker, where you're not gonna get yourself into trouble. You wouldn't wanna do this in a production database, but it is a great learning tool if you do it in a very safe sandbox environment. In terms of auto moderation as well is another thing you could do with a Discord bot. Hey, create auto mod that filters these words. I wanna prevent spam if you do five messages in three seconds, or I wanna warn users about different timeouts. I want you to do immune rules for staff. And so again, the AI system could do word filtering rate limiting warning database. So it really is a way to explore things more quickly. But again, you should always check the output of what's being generated and be prepared to iterate. External APIs through descriptions. One of the things that is available is the ability to do weather, right? Show me the weather for a user city or crypto. I wanna see the Bitcoin price or games get Minecraft server status or memes. I wanna see a random meme from Reddit or music or translations. And because you've hooked up your bot to those APIs, and it has, for example, the templating style that I show in this course, you can actually get very deterministic results. In terms of conversational debugging, again, it would be an error, a describe, an AI analyze, fix generated, then working. So you would say, look, the bot crashes when someone joins. Okay, well, let's check if the welcome channel exists. Oh, it still fails for users without avatars, okay, great. Let's go ahead and add a fallback. So just like traditional programming, you have to be prepared to iterate over and over and over again until you get to a conclusion. You also wanna optimize through dialogue. So the initial prompt would be, hey, the bot feels slow. The AI response is, it adds caching, batch, async, and then it becomes faster. But again, you may have to iterate several times. In terms of security review as well, you could ask questions like, review my bot for security issues, rate limiting to all commands, validate all user inputs. But what you may wanna do as well is ask first before you get into each of these individual prompts, is, what are the idiomatic security best practices for Discord, right? And then you get a list and you even could say, well, I want you to show me the top five. And then you could ask on each of these, do you have this first security issue resolve? And if you say no, okay, go ahead and create a checklist inside of the roadmap and let's go ahead and prioritize this and solve it right now. In terms of test generation through AI, again, let's go ahead and generate tests for these commands. I want you to show me the test coverage. Is the test coverage 80%, what about integration tests? Do we have integration tests, what about edge cases? Or create a comprehensive test suite with Jest. In terms of zero config deploys, you also could take, let's say in the case of Dyno, which does the binary deploy or rust as well, with the binary deploy with universal bot, you could say, look, take this bot deploy to Heroku, and then the AI would build the configuration. And then you could say, look, I wanted to auto restart on crash. In terms of hosting platforms, Heroku, we also have Replit, we also have Raspberry Pi, Oracle or AWS or Google Cloud. There's lots of different places to host things. And then in terms of monitoring and maintenance, again, you could also ask for these kinds of things. You could say, look, I want you to do logging. I want you to track bot uptime. I want you to do a metrics dashboard. I want you to look at the error rates. In some cases, you could just get it in text or you could actually ask for it to create, let's say, a GitHub actions job that goes through and gives you a report via email every day. In terms of conversation templates, again, this is where the templating that I cover later in the course comes in to play. But if you've templated things with yaml, it makes it much more deterministic. Instead of just taking a raw text and getting it back, you would want to add these templates. And the templates get filled out from the response from the large language model, like feature requests, integrations, bug fix or enhancement. Some of the advanced things that you can do with a bot would be music verification. You could also look at economy like building a point system, tickets, analytics, giveaways. And then in terms of the GitHub repository that we cover in this course, we have the conversation template, the starters, the example bots, some common patterns, and then we also talk about the bot itself. And then in terms of the journey through this course, you could start with no experience, and then the first bot goes online. Second, the commands are working. Third, a database is integrated, four, fully debugged. And then finally, you're complete. So in theory, you can build very quickly, especially if you use the starter code. In terms of course success metrics some of the things that you can do with this course is you can start a lot quicker because the code's already been written and it could deploy to production very quickly. In terms of prompt engineering, again, the things to be careful of are be very specific, provide examples, iterate, build a roadmap, test immediately. Don't just blindly accept the first response or use vague descriptions or skip error handling, or ignore security or deploy the code that has never been tested locally. And then in terms of the community, where these are all things that people could do to share the things that they've developed, their own Discord server, GitHub, YouTube, maybe make a blog post as well. And then in terms of the remembering, right, it's the paradigm shift is you're thinking of features not necessarily in code. Describe it, don't implement it, iterate, don't perfect, test early and often, and you can build a bot, complex systems, production apps. And the limit is really just your imagination. In terms of mastering this particular course with the universal bot architecture, you're gonna need to clone this repo, which is github.com/paiml, and then inside the universal bot repo, this is the Rust repo that contains a very solid architecture that you can extend with quad code. And then the challenge is, can you build multiple bots that do different things, deploy to production? And then again, there's a bonus repo that we'll talk about later in the course, and you can also use that repo as well. Alright, we have a lot to cover. Let's go ahead and get started.

Contents