How to host a Nodejs Discord bot on AWS Lambda (free-tier)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey how's it going everyone this is just going to be a simple introductory on how to create a Discord bot using AWS primarily we're going to be using the Lambda piece with no JS so yeah this is out on the uh GitHub it's a public repo you should just be able to pull it down if you want and get started um already included some slash commands here so you can kind of just install it and not have to really worry about anything and kind of give you idea of what it's like to have just more than one example um yeah let's go ahead and get started so we can probably just do the Lambda piece or the Discord piece let's just go and create this this should be fine that's fine going to do function URL with none and we need the cores here cool um so we got that and then we can go ahead and create our Discord bot this is in the Discord developer portal so you just name your application bot whatever you want to name it and we'll need these and we'll need the uh token a bit later but we can go ahead and copy this public key here we're going to create an environment variable needs to be all caps just because that's how it is based on the the coding you can change it if you want in the the index here it's just referencing this public key uh resource and again the reason we're doing that is we just don't want to show it up as clear text go back to Lambda here we need this function URL for this and this probably is is going to fail right off the top yeah so this is going to fail the reason this is failing more than likely because it's not validating I mean technically there's nothing there so there's nothing to interact with so that makes sense but primarily the other reason it's going to fail is because of this it needs this tweet neckel and it needs these verification handlers all this stuff this is all part of Discord it posted it in the document here as well in the read me so you'll see the tweet knle and if you click on this it'll pretty much take to what Discord has um we'll just create a new server here aome so now we got simple server with simple bot and so right now this is open everywhere and we're going to end up changing this here um with a few things we'll wait until we go ahead and get this developed let's go ahead and get the um ID here we'll need this for uh Reg registering your commands so we're going to CD into Lambda files here and then we would run our commands which gives us the the modules and the package basically this piece is done so if you wanted to you can just go into your Lambda files you can just include all of this so we're going to upload from zip file so there's that and this should pretty much be good so if we come in here General we'll have to recopy this again and that worked correctly and if you like refresh this it'll probably internal server because it has that validation piece an extra step you can do if you um want to is in the function URL piece here this allow origin instead of it just being everything you can set it to Discord so that way you're just kind of verifying that it's only going to be from Discord and not somewhere else where someone might be trying to like steal or use that um header cool well at this point in time the Lambda piece is pretty much done I don't call if there was something else I think that's good so we're going to close this the app almost ready we need this URL generator IA just go ahead and do these two here this should be for like registering those commands and then The Botch just shown it up as a bot in your um your Discord then slash commands that's primarily what we're using here simple server SL commands cool and you can see right here and we don't have any so if you hit slash there's nothing here yet except for like the default so in this situation let's go back we're going to go to Global we need to run this here and explain what this is the axio is pretty much for the um query and posting of the Discord API URL which would be this stuff and then the the EnV is basically to reference the EnV file your environment variables so you're not passing in hardcoded secret keys and whatnot awesome so that's there and then we just do node register three commands have been registered so if you go back to Discord there it is so there's our bot and now it's okay now it's shown it twice so it's shown it twice because it has the guild and the globals so you could just Purge um either or whichever one but basically here you go there's hello uh let me know if you all have any questions or any concerns or issues I'll try to address them I'm not a nodejs expert so if you're trying to do some super crazy stuff you might have to find a different material Source or just chat GPT um I honestly I use a lot of chat GPT to try to help out with some of my configurations kind of trial on error yeah um there you go
Info
Channel: crispb
Views: 443
Rating: undefined out of 5
Keywords: discord, bot, nodejs, lambda, aws
Id: dglRjf17gJs
Channel Id: undefined
Length: 6min 53sec (413 seconds)
Published: Fri Jan 19 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.