Make a Low Code Discord Bot with Integromat Part 1 and Part 2
For instruction on how to create a discord bot, and for the base code used in part 2, see here: https://www.codementor.io/@garethdwye...
Part 2: https://www.youtube.com/watch?v=ddiy2...
Sites I mention:-
https://www.integromat.com/?pc=pragma... (This is our integromat partner link, it helps us if you use it!)
- https://cryptoraiders.xyz/
- (discord: https://discord.gg/mjeepcHJXE)
- https://nomics.com/
Part One Transcript
Hey everyone. Welcome. So today what we're gonna do is build a couple of basic discord bots. What do these bots do? Well, you can see the end result right here. These are for a really awesome game and awesome community called crypto Raiders. And these will report the price of their token. And that way, those values can be in discord instead of having to go to various sites to look them up.
Alright. So how do we build this now? The way I built it was with a combination of a few things. One of those things was integr met and that's, what's actually getting the data and passing it to the bots. So part one, we're gonna just look at that. So how does this work? I've used three HTTP requests.
The reason is that I have two bots to upgrade. If I only had one, this would be two modules. I wouldn't need the router. Now an integr map, basically just start a new. Scenario and go and choose the HTTP request module. And when you get in there you can go and first of all, hit show advanced settings and make sure that you evaluate all states' errors except for 200 and 300 cause otherwise Integra won't recognize errors.
The other thing you want to do just for basic setup is select parse response over here. That way the response data is gonna be usable in the next modules without that takes a little bit more. So we are going to get some data from Nomics. NOx is a really awesome site, at least in my opinion. And they let you, I mean, one, the, the collection of tokens is awesome.
The UI is really great. And then you can go and compare in every different type of currency or pairing that you wanna see. So also a really nifty feature. You can click up here and then they'll take you to get an API key and you. Basically need to you can get a free one and that'll be enough, even though it's not perfectly ideal and I'll explain why it still gets the job done.
And I think their base key is like 5k. So, you know so we're gonna query the prices. API. So this is the URL and you can find that in their documentation. And then we have key equals well, I'm not putting my key here, even though I think it's a public one, but you know, good practice. So you know, no parentheses just paste the key in there.
Now I also have this header section where the value key is being. I was surprised I needed both. I'm not sure about it, but when I removed it from the URL, it stopped working. So I have both you can play around with it. And again, here, the actual key value past that point, you don't actually need request content so you can leave this empty.
I was just playing around with it. And this is, this is all you need. And so when you run this, let me show you in this guy over here. So when you run this, you're gonna get a massive. Dump like a rather large one look at this file size. It's it's sadly very large, cuz I don't yet know how to specify the yeah.
Sorry. How to, how to specify the specific coins I want to get. I'm not sure if it's actually allowed at least on the free API. So then when you check in the data section then you can see, you know, here is the token, so we have currency and price, and this is just a large list of currency and price key pairs.
So what we're going to do in the later modules is just pull out the one that we want. So if we take a look at that and yeah, let's take a look at the radar module. So here, first of all, we are pinging the discord app, right? I have created a bot in discord. That's really important to say on the discord side of things, you need to create an app.
There's tons of. Guides for that. So I'm just not covering it, but I will put a link in the description and that doesn't take too too long. You do need to make sure to give that bot when you share the link, give that bot permission to change its own nickname, cuz that's the mechanism we're using here.
So discord app, API guilds. This is the ID of the Guild that you are putting the bottom that you want to. Sorry, where you want it to basically work an update so that you can get from the URL is the easiest place. If you take a look in the discord web app and then slash members and at me, so basically based on the bot token that you'll put here, that you'll get from discord and that's the secret token.
So don't share it. There's a reason I'm not showing it here. Dynamics one. Isn't very sensitive, but this one. And I could be wrong about the NOx one. But yeah. So do not share that key cuz it's the password to your bot. So here, because we're sending that token and because discord can identify, you know, which bot that token belongs to, we're saying at me, that's what we're changing.
So again here authorization bought plus. Token. So bot is specifying that this is a bot type token. And then if we go into the body type, I tried putting this in the query string. It didn't. It might work. I just, I don't know. This seemed better. So body type raw, Jason, again, you wanna parse response.
Although at this point it probably doesn't matter too much. And again, here I did hit show advanced settings and, and make sure that the you know, error are being registered properly here. So what's happening is the content I'm gonna send. And if you take a look at the API documentation for that URL, it'll explain a little bit more thoroughly why I did.
But the value that I want to change. And I think the only one I can change with this call is Nick or nickname. That's what they called it. And then what I want to change it to is, you know, the name is Rader. This is the formatting of the bot. Let's just pull that up on screen again so you can see it.
So, you know, and all I want to change is after the dollar sign. So how do I get that? Well, the formatting here, isn't the most beautiful. But if I just try and make it a little more legible right now, then here's what we get. So the starting from the inside, the first thing is that we're taking this whole data array.
I showed you, it was a big list of key value pairings. And we're going to map that into a single dimension array or just a list and the way we're gonna do it, that list is only gonna have one valve. So it is a mapping of this array. Only of the price value, and we're only gonna take the price value where the currency is equal to Rader.
So if you hold over map here, you can see the formatting at once in case you forget. So it's this oh no, it's this bottom line that we've done. And yeah, so basically from there, we're going to get. The first value of that array, it's the only value. And then we're gonna parse it as a number. And the reason I'm doing that is cause I wanna format it, but I can't format a string as a number.
So we're gonna convert it into a number. And you can see here, it just wants you to specify the decimal separator. And then finally we're gonna format the number. And if you take a look at that, it is numbered decimal points and decimal separators. Number of decimals, then the decimal separator and then the thousand separator.
So that's what it calls for. And then we close out our query here and and that's it. So basically with the actual key plugged in, it works. So let me show you the end result. One more time. We are going to take a look at where is it? So these bots, and maybe I can do this nice and quick. So this is the actual one it's gonna.
So I'm gonna hit, run and switch back and maybe we'll see it happen live. Maybe we won't. Oh, there it is. So you saw that one update and if we take a look over here once again, you know, you can see this ran successfully. And if you don't click that. You know, treat 400, 500 statuses as errors that then even if this had an error would show green, you wouldn't know.
So that's why we want to do it. So if you only go this far, if you've created the bot on discord, and if you have set up this integr net routine, then you're gonna have these bots that are gonna work, but they won't show us online. So in part two, what we're going to do is show you how to get the bots.
So that's coming up right next. Assuming YouTube's algorithm is doing its job properly. Well, the way I want it to do it, I guess. And yeah, if you've enjoyed this, then just like subscribe. I think if it's not mirrored, you know, you know where the button is at this point. So thank you guys for watching.
And if you like this, you know, we run on props. So if you comment, if you subscribe all that and this is useful, then we'll make more of these videos. So thank you guys very much.
Part Two Transcript
All right, welcome back. And now we're gonna do part two of these super cool bots that are going to report. The token value of a token has pulled by Nomics in a discord so that we don't have to leave in order to see it. And we can show our token price, dollar members. Super cool. So if you followed part one, then you already have this working, but the bot will not show as online.
And so the thing that we need to do is well set up set up a server. So that, that happens. So let's go over to here it is rep.com and this repository I'll, I'll give the link. You can access it. None of this code is originally mine. I think I changed like one thing maybe. And yeah, so basically this is the first Python script I've written.
You'll notice as I try to explain it to you, I'm maybe not even that knowledgeable, but it does work. And yeah, so that, that's the good news. So, you know, we're importing our packets here. You have, this is import discord actually wonder if I'm supposed to update it to import discord. P Y if you take a look at the packages.
Importing this, this, this is basically a rapper, so you can interact with discords API flask. I'm actually not sure what it does, but it was part of the script that was recommended for keep alive. So those are the two files that we have. So you can copy and paste this and it, it largely should work.
The only modification you'll have to do is token OS dot environment dot get here. This is basically pulling the token value. If I put it in the code, people could see it and that wouldn't be very secure. So instead you go to secrets, environmental variables, and these are kept secret. And then you'll see right here, you can create a new one.
So you can call that token or you can name it, whatever you want. And then you just update. Over here, the name of the token. So I think even, yeah, there's an extra line of code in here, maybe. But so we have two basic purposes that are going on here. One is, you know, just the, the general housing and importing the packets and all that, like the, the wrapper.
And then there is the actual keep alive function over here. So you can see what that does. You can copy paste. It basically returns I'm alive. And so we have something to, to ping here. So this keep alive function. What it's gonna do is it's just gonna get the token and then it's gonna do client.run using the token.
And so what that's gonna do is just run the bot. It's not actually doing anything and there's no function, but it's keeping the bot alive because it's done an action. So we need to run that at least once an hour, because on the. Plan of relet anyways or, sorry in discord, if the bot doesn't have activity, I'm pretty sure it's within an hour, then it goes offline.
So the problem with free relet is that it doesn't let you keep the server alive for very long. Once you have points, you've closed the browser window, but we have a solution for that. So if you grab this URL right here and that's only gonna pop up, once you hit. So if you grab that, we can go over to uptime robot.
You can add a new monitor and I'm gonna show you how I have set this up. So the first thing here, let me just show you edit. All right. So the first thing is you're gonna choose HTTPS. Then you put in a friendly name, then you paste in the URL that we just grabbed from the other pages, server URL. The monitoring interval, every 30 minutes is working so far.
So that seems to be fine. And, and that's it. So you can set up a contact email if you would like to have notifications when it pings the server and the server, you know, doesn't respond like, Hey, I'm alright that doesn't give if it's 200 responsible and yeah, with that combination of things, you're basically good to go.
So I've been testing this for two days now on my server, the bots have stayed. And that's really great news. So if you have questions about the script, you can post them in the comments. Again, I'm gonna put credit in the, in the description, cuz I forget where I got this from, but it was super useful.
It was very fast to set this whole thing up and yeah, I hope this is really useful to you guys. Cause now you can, whether or not you're doing the token bot, this part is going. Keep your bots alive, whatever functionality they have. And if you learn integr map, or if you learn Python or whatever other script, you can actually do this in like JavaScript and, and in node which started to get away from me a little bit.
So I didn't. But yeah, you can, you can modify this. And probably the next thing I'll do is take the integr map parts, which right now it's running like two, $3 a month worth of requests. But I'm pretty sure I can bring it over here and bring that down. And instead of running every hour, we can maybe run every 15 minutes or more frequently.
So I'm gonna test that all out next. But again, hope this is useful. Thank you guys for being here and for watching as always we run on props or maybe we run on, you know, crowd votes. So if this video is useful, we'll make more of them. Just let us know, give us thumbs up, like subscribe all that. And then we'll just pop out more of these things for you guys.
So thank you so much and enjoy happy.