Menu
header photo

The Journaling of Sparks 090

appealvan71's blog

blog post

a way to make a Discord Bot in Python! (Part 3: Joining/Leaving Voice Channels)(2021)
hello friends it is james and welcome or. welcome back to my channel. so it truly is side three to making a. discord bot. in python in part one i confirmed you the way. to set up your bot. partially we went over instructions pursuits. and detecting whilst a consumer leaves and. joins a server. one of the matters we received it to do when a. user joins the server. is that it will greet them and then additionally . deliver them a random funny story. it receives this funny story from a random api that. we. known as so i will be leaving a link within the . description to these two videos so move. watch those. if you haven't already but let's get. into side 3. so what are we going to be doing we're. going to be staring at. permitting our bot to affix voice channels. and for it to depart voice channels. after which in the subsequent episode we are going. to get it so it could play. songs like documents that you've in your.
desktop or. video clips from youtube so remain tuned for. that so let's simply leap immediately into it. so let's begin coding it on the way to enable. our bot. to affix a voice channel so before we are able to. begin writing the code we need to. set up an. extra python package this python kit. that we will be. installation works with discord p why it is. made by using the those who make discord py. and iit's essentially the package allows. your bot to. become a member of a voice channel you must have. this package set up to your bot to. use a voice channel so yeah let's let's. cross ahead and iinstall that. so in your terminal you want to run the. following command. i'll go away this command iin the. description. um so you could simply go ahead and replica and. paste it from there. and then you want to move ahead and run it. i've already established. this so i need not run it returned yet.
Once you've installed it. that is it you have now installed all the. applications we need to. permit our bot to hook up with a voice. channel so let's scroll down. and let's create a new command so we're. going to do it like i showed you. in the last episode so we will do. at client. dot command open and shut brackets. move underscore context. is the same as real i didn't speak. about what past underscore context does. in the last video. i'm not going to go into it now because. i will say that for a later video. because it receives genuinely interesting then. but just do not forget that we're going to. desire it for when we're speaking. with. the voice part of our bot and then under. right here we'll define. the operate we will say async. def. and now we need to deliver our function the. call so in my case in our case we are.
Going to call trello discord bot . join and then open and close brackets. back and then ctx. after which a colon ctx if you don't. remember from the beyond episodes. it basically just aallows you to. communicate together with your discord server in. a sense it lets you ship messages. and receive messages in addition to other. properties like about clients and channels. and so on. so then we want to create an if. announcement and you may see why in a second. wherein we'll be creating this so. we will say. if and open and close brackets ctx. dot author dot voice. after which close bracket after which and. column and i'll explain in a second why. we are developing thiis if assertion and. what it does. after which inside of thiis if declaration we. want to variety channel. is equal to. ctx.message.author.voice.channel. after which we wish to do a new line and. then sort await.


And then channel dot connect. op

Go Back

Comment

Blog Search

Comments

There are currently no blog comments.