really seen a lot.both. oh ok good i'm able to


music bot for discord
Code Your own Discord Bot - Member Counter (2021)
What is going on men welcome back to. a different discord.js academic in state-of-the-art. academic we are going to be coding a. member counter how we will be. doing its having a particular. voice channel that is going to trace the. volume of participants that we currently have. on our server so it will say total. members. whatever like 5 due to the fact weve 5 . members so the first thing we are gonna. do is really create. a voice channel so go ahead and create a. voice channel you could call it whatsoever. you desire we are gonna name it complete. individuals with a colon and we need to edit. many of the permissions. due to the fact we dont need to allow persons. enter the voice channel. to be able to voice connector permissions. attach lets disable that youll be able to. disable every little thing yet the only issue . you actually do have got to disable. is the attach permission alright.
We are also going to pull. the channel all of the way up here so while. persons join this is the article theyre. going to determine up top. and lets pass forward and get started if. youre new here make sure to watch. the first video of this playlist which. is how to set up your discord bots and. mounted all of your environments. but thats basically all youre going. to want alright so what we have to do. is we presently have a folder for our. commands. yet we additionally desire to have a folder for. events and. counters so what i am gonna do is. actually create a brand new folder in our. whole overall task. and this folder is gonna named counters. now you can name it whatever you want. yet were gonna have distinctive counters. so were gonna code. in a while like a youtube counter or like. a subscriber counter. whatever you are able to do im simply gonna name.
This folder counter to be able to preserve all. of our counters. within this folder so were gonna. name it counters. and iinside the counters folder were. gonna create a javascript file for our. member counter. so it is gonna be member dash counter. and it has to be js so allow me rename. that member counter dot. js in our main dossier. we actually have to require this. specific dossier here. so were going to do const and we are. going to name this member. counter it will equivalent require. and were going to require that categorical. dossier now we did it in. the counters folder so were going to do. interval backslash or. cut back and well pass into the. counters folder. and well get the member. counter file. now to actually basically run this. overall dossier we actually have to move down. into our purchaser.on. all set and iinside this occasion we want to.
Get our member counter. open it up with parentheses and pass in. client. due to the fact we are going to need to use. purchaser inside this dossier. alright so lets pass forward and get. started so we will do a module. exports how we do with every single. command. so module exports and iits going to be. equal to an async. so we will do an asynchronous. command here or event. or counter and were going to open up. with parentheses and well pass. in. that client that we received from our main. file so lets open this up. and in here the first thing were gonna. want is the guild or the quote unquote. server. so move into your discord and copy your. guild identification. simply arise right here to the name of your. server right click replica identification. so well be doing const guild. equals purchaser dot guilds. that cache that get and here.
we will paste in our guild identity. so theres actually a pair approaches you. can actually do this the manner were going. to be doing it in this tutorial is by using. having a set. period so each as an exle five seconds. it is gonna verify the quantity of members. in your discord server. and then replace that dossier or replace that. channel so we do set period. and in here we are going to do an arrow. operate. the code will be in the description if. you guys want to copy the code. and in right here were going to do const and. we will get the member count number and. the manner we get the member count number. is we will do guild dot member. account. the subsequent element we will do is get. our channel the channel that is going to. be updated whilst somebody joins. or leaves the server so we are gonna name. the cons channel. and this is going to equal to guild dot.
Channels. cache i get. and here we wanna get the channel id so. pass into your discord. right click on the channel and duplicate id. there it is rather like that and now we. simply desire to simply set. the channel name to anything specific. so channel. that is set call and in here we wish to. do. a backtick which is the most important subsequent to one. and we wish to name our channel so we. named it total individuals. complete participants colon so lets do that. first total. members colon after which in right here we want. to do a space. with a cash sign brackets and in here. we want to do. member count dot to local. string now the explanation we are doing . regional string. is due to the fact for instance youve more than. 1000 contributors. and you dont need to send 1000. like this you desire the bot. to label or ship the thousand as you. might have the ability to read it. or write it in real lifestyles so with a comma.
So that is what nearby string does. rather than simply having this quantity. it will ship it with the commas. okay and the very last thing were just. going to console.log because we want to. examine. every time and its updating so were. just going to console.log updating. member accounts. and then in among the brackets and the. parentheses down here let me just make. this slightly larger. in among the bracket and the. parentheses we want to do a comma. and we wish to set the amount of time so. lets do 5000 ms. that actually must be it so i am gonna. move forward and run. our bot and we should not get any mistakes. and every five milliseconds or ms we. ought to have the ability to get or. its probably not every 5 its extra. like several five seconds we must be. getting um. the updating member count now lower back. 5000 milliseconds is 5 seconds.
So lets move into our discord server. we are presently a total 5 contributors so. im gonna get my dummy account. genuine rapid permit me log in. and well show up on line in a. moment. ideal now lets cross ahead and leave the. server. this could drop all the way down to four there it. is. and thats the way you do a member counter. so lets cross ahead and become a member of a different time. now it should be up to date to 5 the. subsequent time it does it. and it did not replace to 5 now why. is not it updating to. five now like i said in the beginning of. the video there is this new like method. that discord carried out and it made it. notably tough for bots to get a number of. information. from a discord server so allow me show you. what is correctly happening. i am gonna go into my other account and. as you will find it actually says theres. already 5 individuals. within the discord server despite the fact that i left.
It. its gonna take a while for this to. replace and once it updates this. goes to update so in many instances it will. take the time. due to the new strategies that discord. further into. their developer you recognize equipment and. portal so ill show you. what they added i confirmed thiis about two. tutorials ago. and thats the privilege gateway. intents. youre gonna must have this on so move. on your discord developer portal. therell be a link in the outline. you need to have this on in case your bot. tracks. the presence intent on the grounds that we are. monitoring the presss intent were. checking what number of people are current. within the server its going to take a long. time for it to detect. as theyve like a little threshold. that they added so cross ahead and go into. your. developer portal and ensure to have. strategy motive on. and server members purpose on and iif you.
Do have. 100 or extra servers that your bot. is in then youre gonna ought to get your. bot established. and whitelisted so they added this. tremendously recently. and it makes it a little more durable to. code bots the image of this one. so you are gonna ought to work with this. method as you will find. it simply up-to-date to five it took some time. yet. thats just the way it has to paintings there is. actually a pair matters that i do wanna. tell you or some thing that i wanna inform. you. is that you actually dont need to have. the set interval at 5 seconds it. surely would not make feel i purely did it. due to the video. but youll want to have it a minimum of. anything like. 15 perhaps 10 mins you dont want to. update this each moment. lower back its not likely gonna work. youre still gonna have got to watch for the. gateway intents to come in.

Leave a Reply

Your email address will not be published. Required fields are marked *