Placeholder Image

Subtitles section Play video

  • what is going on?

  • A radio.

  • Welcome to part four of the bots in discord with this cord pie tutorial.

  • Siri's in this video.

  • What we're doing is working on attachments how we make an attachment in this case with an image and that image is a graph over time of our least one of our user metrics.

  • Eventually, I'd like to make, like, multiple axes and show mall and stuff.

  • Not gonna get too crazy with that here.

  • Mostly I just want to show you guys how you can make an attachment.

  • So to begin, we need to first actually graph the metric, um, the metrics themselves.

  • So let's go over the code for that really, really quickly.

  • Um, or I could just copy paste this bit.

  • I think I'm just gonna copy and paste it.

  • It's in the text based version of editorial, so that link will be in description on dial.

  • Just kind of explain it.

  • So here we're using pandas, Matt, plot lib, um, and changing this style.

  • All this stuff if you don't know anything about pandas or map live, I've got tutorials.

  • All those then overdoing were reading in the user metrics were assigning the column names.

  • Ah, the time is in UNIX time.

  • So then we just convert the time to an actual date time we compute a total column because eventually, I'd like to show total users over time like that user growth.

  • Um, Then we get get rid of the time column itself.

  • Because I see you next time we don't care about that.

  • We're gonna set the date as the index later we can re sample.

  • Like, right now, this is every five seconds is there's way too much.

  • And later, if you wanted to show a big graph, you might have way too much data.

  • You might want to re sample or something.

  • But for now, it's good enough, Uh, in this case, we print the head just to see what we're working with.

  • We plot, show the legend, show the plot and then save the actual figure.

  • So let me go ahead and run that real quick so you could just see.

  • So this will be the graph that we show there's just dead time.

  • Here's the pot.

  • Wasn't actually connected to the server.

  • I was.

  • This is probably where I was filming a tutorial, actually.

  • So, um anyway, you can see the growth over time.

  • This is just the last.

  • I don't know, 40 minutes.

  • So yet, um, I didn't have enough patience to wait a few days.

  • So?

  • So here we are.

  • I didn't actually know the answer to this question, so we had to figure it out.

  • Uh, okay.

  • So, uh, so this is the code that we want to do to actually save the image.

  • So basically, we want to take this code and add it to that background.

  • Um, you know, the user metrics background.

  • So I am going to copy this code, come over here and basically, after we save the metric let's just paste, let's tab this stuff over.

  • Great.

  • And then before, before we actually start plotting, let's do a p l t dot seal left.

  • That should clear the figure.

  • If we don't do that, what's gonna happen is every time.

  • Because first of all, we're not going to do a show.

  • We are gonna save the figure locally.

  • If we don't do this, basically every five seconds, this background task is gonna run, and it's going to see this plot operation.

  • We're sharing the axis, so it's just gonna keep?

  • Yeah, it's just gonna keep plotting that lion.

  • But then it's gonna have, like, the legend will just be like a bunch of different colors.

  • It'll mess it up.

  • So we're gonna clear the figure every single time.

  • Then when we're done, we saved the figure as online dot PNG and then our gold.

  • Here is later when someone goes to call the, you know, community report, it shows the graph.

  • So before we forget, let's also bring in our imports here, some school up paste, that's all of our imports.

  • So now we just want to attach the image itself.

  • So right now it's just local.

  • So under community report, we'll go ahead and keep this output also, just to make it kind of cool.

  • Let's make it pie.

  • Uh, new line eso after it sends that message.

  • That's just like those stats.

  • You know, uh, what we want to do is we're gonna say file, and that's gonna equal a discord dot file.

  • And then we specify that file.

  • It's going to be online dot PNG and the file name itself online dot PNG.

  • Then what we want to do is a wait and then we're going to message dot channel channel dot send and then we're going to send online on line dot PNG and then file equals file.

  • So this will be like, whatever you put here, I believe will be, like, kind of like the title text to the actual thing.

  • Um, And then this will be the thing that it actually attach is if you forget PNG, it'll still attached, but I'm pretty sure it doesn't convert it to an image.

  • It needs to be on, like, a dot PNG or something like that.

  • Okay, so I think, uh, I think with all that, we're ready to rumble.

  • So let's go ahead and save that.

  • Let's start the baht.

  • Hopefully, we didn't forget something.

  • We'll find out soon enough.

  • I just kinda want to see it.

  • Uh, speaking of scar hardwood, we're still printing out the head.

  • Let me just comment that out.

  • I should have had that are actually we just delete it.

  • So it appears that that's all running.

  • And if I open up here is the image.

  • So again you can see there's a gap there.

  • I'm filming this tutorial.

  • So anyways, uh, let me close that.

  • So we're hoping to be able to attach that sub.

  • Let's come over here.

  • Copy community report and let's paste awesome.

  • So there you have that, like online dot PNG.

  • But you could call it like anything you wanted anyways, So now we have attached this lovely awesome graph.

  • Um might be cool to, like, maybe make the background the same color as discord off to grab that color for at least the dark theme and then, like, make these lighter that we kind of need.

  • Then it would look like it's almost see through.

  • I think that's probably what I'm gonna do.

  • But I'll spare you guys that also probably include, you know, total users over time and all that stuff and try to make a little more fancy.

  • But for now, that's pretty cool.

  • So this body is slowly coming together.

  • So probably at this point, I'm gonna I'm not sure what else I really want to show you guys as faras basic discord Pie is concerned.

  • If there's like some sort of task that you'd really like to see, let me know down below, or if you've got some sort of cool suggestion to add to the body the only thing I really haven't shown you guys is a search functionality for tutorials.

  • But besides that, anything else, eyes, I'd be interested to hear what you guys are looking for.

  • So with that as usual quick shoutout to my recent new sort of knew, I recognize two of these names members opponent, no funny Newcastle geek and Joe A Bass Tooley, Newcastle, Deacon, Joe past Julie.

  • Are you guys re upping as members?

  • Because some people say that they don't show up on that list again, but certain names do so comment below.

  • Let me know if you're just, like, canceling every time and re upping.

  • Or what?

  • If you didn't know howto support and you haven't watched the other ones?

  • Don't forget there's that beautiful button down below.

  • Okay, that's it for now.

  • If you guys wanna come and hang out this court dot g slash sent, Dex.

  • Otherwise, let me know again what you guys want to see if you want any other content with this court pie.

  • Otherwise so, pride be the end as I start to kind of work on my bought.

what is going on?

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it