Placeholder Image

字幕列表 影片播放

  • What's going on?

  • Everybody, Welcome to part two of our discord Pie bought tutorial In this tutorial, we're just gonna start building out an actual.

  • But the only thing has changed from last tutorial is I've just started saving the token and a file so I don't have to show you guys my token and I don't forget about it and all that.

  • So, uh, let's go and get started.

  • So the first thing that we probably want to do immediately out of the gate is right now when we break, our client, uh, bought doesn't exactly log out for quite a while.

  • Sometimes it's like I've seen it sit there for, like, an hour.

  • So?

  • So we definitely want to be able to, like, have the baht leave at some point.

  • So, for example, we could do that.

  • It's simple as, uh, get out of here.

  • Two exclamation marks in message content dot lower, um, or you could do double equals even to make it like a command.

  • Um, Then what we want to do is rather than message dot send, we could await a client dot clothes.

  • So anytime it's a co routine.

  • So if you go look at the docks, and it says it's a code routine.

  • You have to await the co routine.

  • If you don't wait, it basically the, you know, throw that command out.

  • But then you'll carry on and forget all about it.

  • So you would.

  • You just want to be a very good idea.

  • So we'll await client dot clothes, and then that's that.

  • So the first thing that will do now is let's just go ahead and save and run that real quick.

  • So I ran it.

  • There's my body, and then what we can say is, What did I say?

  • Get out of here double.

  • So get out of here.

  • And there he goes.

  • He's gone so easy enough.

  • So that's one thing we want to go ahead and add to her bought.

  • Now, what I'd like to do is so you could say, you know, log out, you know, make it some sort of command for your actual thought.

  • Since I'm calling lines sent a body and this is some sort of, uh, you know, it's it's a Python channel.

  • It's about that's gonna reside on Python Channel.

  • I'm just kind of making everything like it's a method so I'm gonna say if Santa bought dot Log out in message content dot lower.

  • I'm actually not even sure.

  • I guess we we've done the client dot close, but we haven't broke away.

  • Client got close and that we could do, like, an exit or something.

  • But for now, I'm gonna cancel that.

  • Um Okay, so, uh, the next thing I want to do is, um, we come up to my channel and s o Let's go ahead and start adding, um, like, so send a pot dot log.

  • Oh, what if we want to get like, for example, I want to start tracking, uh, like users on the actual on the actual server.

  • So one of the ways that we can do that is with, like, by counting members.

  • And then we can also do things like seeing who's online.

  • Whose idol?

  • Whose offline who's got, like, do not disturb all that kind of stuff so we can start pulling in that kind of information when we referenced the actual guilt Now to get your guild, you just need your i D.

  • So right, click any server copy that I D.

  • And that's the actual I d for your Guild, which is used to be called a server.

  • So if you're looking up like, uh, stuff that you can do with that and you see an example and it uses, like client dot server, just know that that's our client dot get server.

  • It's now it's get guild.

  • I'm not sure why they made that change.

  • I'm I know discord is for gaming, but discord calls it server, and I'm not sure if discord plans to call it guilt, but whatever.

  • Okay, so, um, so that's what we're gonna do.

  • So first of all, we're going to say, at least for me, you could say guild equals.

  • Um and it would be easier for other people to read your code, but I'm gonna call it Centex killed, and you can call it whatever you know, your guild is called and I'm gonna do client dot get guild and you get the guild by the idea.

  • And I just right click my server and got the I.

  • D.

  • You also can do like I forget what the command is.

  • There is there's like a way that you can get all the guilds.

  • I can't remember what it is, but anyway, you could cycle through all the guilds that you're bought has access to and then figure it out by name or something, Dad, or you could just right click it this way.

  • So once we have the guild and the next thing that we could do is we could make a command that gives us information about that guilt.

  • So the next question that we could say is, in fact, I think I'm gonna We'll just start calling these l if statements.

  • So we'll start with If, um so if sent a bond dot member count and then in this case, we're gonna say double equals.

  • And then we price should say that here is well so rather than in message dot content that lower were going to say it has to be exactly that, because otherwise it would be a syntax error, right?

  • Ah, such a nerd.

  • Okay, so sent extra member accounts.

  • Um, if that is your message, content starts lower.

  • And in theory, we could stop using lower, because it should be this exact command.

  • Um, okay, so if it is, that's let's go ahead and await message dot channel dot Send.

  • And then what?

  • We're gonna send is another F string.

  • And, um, in fact, we could send it in these, like the code blocks.

  • I think that's right.

  • Three of them.

  • Yeah.

  • So you could say, um and then make sense.

  • Snap string.

  • We could say Centex.

  • Underscore guild dot Uh, member underscore Count Now, um, initially, my thought was to act to keep this as an attributes, as it is an attribute here.

  • Um, but then, as I started thinking about everything, pretty much everything else is gonna end up being, like all method.

  • Um, and that was gonna be really confusing.

  • So I'm gonna make it a method if that bothers somebody, which is shouldn't.

  • But if it does, you know what to do.

  • So you can change it yourself.

  • So, actually, I'm going to say it's a python code block new line, and then we'll print out the member account.

  • Let's go ahead and save that.

  • Let's run that.

  • Hopefully we're all good.

  • Okay?

  • We've logged in one of the boxes talking and let me come down here.

  • So now if I call center but dot member accounts sent If I dive member Oh, my gosh.

  • I get tough dues.

  • He responds Okay, We've got 8188 members in the server.

  • And then let's go ahead and do ah scented body dot Log out incentive on, doc.

  • Log out.

  • Good day.

  • I don't like you anyways.

  • Okay, um, so wondering if if maybe what we could do is I don't really know.

  • Elsie.

  • Import cysts insist on accident.

  • I'm not sure if that's enough to cleanly exit.

  • Let's just try that really quick.

  • Um, Okay, cool.

  • That way we're not hitting that silly air any more.

  • Soldiers await client dot clothes.

  • Um, and then we go ahead and exit.

  • Okay, so that's pretty much all I really want to cover in this one.

  • I do have one more thing that's in the text based version is editorial.

  • And maybe what I'll do is I'll just copy and paste it.

  • There's really nothing fancy here that's, like, new or a new concept.

  • So I just think that's just what I'm gonna do.

  • So I'm gonna just, uh, copy that.

  • Oh, it did get me.

  • I gotta figure out howto like close all this.

  • The threads when you're, like, running a synchronously.

  • Not really sure.

  • Anyways, uh, not my problem right this instant tools cancel.

  • But if you know the answer to that, let me know.

  • Otherwise, I'll probably google it after I'm done with this tutorial and figure it out anyway, Um, so the other thing that we could do is LF sent a bite.

  • So in this case, LF sent about dot community report, if that's the thing that we ask, what we can do is we can generate through all of the guild members, and then each member has a status attributes.

  • Um, and that'll be online offline.

  • It might be idle.

  • It might be dnd for Do not disturb and other things.

  • So, um, I'm just gonna call anybody who's Idol or some other status other than online or offline.

  • We're going to say that's idle.

  • So then what we can do is, um and again, I might want to call this pie, but I'll just leave it this way for now, we can worry about you can worry about formatting that stuff later.

  • There are various like Mark Downs that you can use and stuff, but we'll just stick with this.

  • So, uh, let's go ahead and run that, and then I'm just gonna copy this and then I'll bring this over here.

  • Paste.

  • Okay, so this gives us the actual realistic numbers.

  • So in this case, there's 2267 people that are actually on line.

  • 523 are idle, busy or do not disturb.

  • And then off line 7665 Which is interesting, because that doesn't I quite agree with this number.

  • Here, this is 505 people are online.

  • I don't know if that has to do with, like, if they're invisible or something like that, which is very well made.

  • Um, I don't know someone again, If I'm missing something, comment below and let me know what?

  • I've what I've done wrong.

  • But I'm pretty sure that online works and then offline works.

  • And then maybe I'm just throwing too much into idol or something like that.

  • I don't really know.

  • Okay.

  • So I think that's enough for this one.

  • And, uh, maybe I'll have one more video as I continue to build this out.

  • The problem is, it's basically just a bunch of this.

  • I mean, you're you're building out, uh, you know, commands.

  • And then those commands, do things.

  • And then to figure out what you can do with commands, you just check out, uh, pull it over the A P I reference.

  • Let's see, Here we go.

  • Um, so if you want to learn more about all the things that you can do, just check out the documentation and there's a whole bunch of stuff that you can do here, Um, I might reserve the next tutorial.

  • What I'd really like to do is like in this community report, um, I would like to be able to start keeping track like maybe run that every I don't know every 30 minutes or 10 minutes or something saved the results to, um, save the results to maybe, like sq light or even just like a C S V file.

  • And then later you could create graphs and then instead, when you do the community report, it would be a report of graphs instead.

  • And then the body can attach files if you give it the permission so it could attach a file of the graphs.

  • When you actually call a community report, you can see grafts over time, so I might do something like that for the next video because, like I said, at some point, it's just a bunch of these simple commands.

  • There's really nothing too fancy about it.

  • Um, I did do a search.

  • Maybe I'll do that if you guys want to see how I, like implemented that search.

  • But basically, that was just a scrape of python programming dot net some regular expressions and boom.

  • The search works.

  • Um, so, yeah, let me know if you want to see the search.

  • Otherwise, I'll probably reserve the next part three to be probably an upgraded community report where, over time we kind of save some of this stuff.

  • Um, also, if you see, this is just because your urine Yeah, like sublime or something.

  • If you run this in a console, it'll just show like little squares.

  • And you won't really You won't get an issue like that.

  • So anyways, uh, that is all for now, Quick.

  • Shut up to my most recent amazing members.

  • Michael Zao Zhang Joseph Coleman cva Gabi An Amper hammer.

  • Thank you guys very, very much for your support.

  • If you didn't know how to support and become a member, just click that beautiful button right there.

  • is cause nice stars around it and stuff join.

  • Boom, done anyways helps me keep doing what I do.

  • I could put up more content quicker the more I can focus on this rather than doing things like contracting consulting.

  • So, um, definitely check it out if you want to support the channel on the content.

  • Also, you get early access to videos just like this one.

  • So that's all for now.

  • Questions, comments, concerns, whatever.

  • Feel free living below or you can join her.

  • Discord, discord, geese last, Syntex.

  • Otherwise I will see you guys another video.

What's going on?

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

構建機器人命令--用Discordpy製作Discord機器人第2頁。 (Building out Bot Commands - making Discord bots with Discordpy p.2)

  • 4 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字