Server-Info Command | Discord.JS V13 Series | #19

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
here's what your command will be looking like after we're done with the episode you're gonna be able to type slash server info and what you're gonna get back is an embed filled with information about the guide all right so we're gonna start out by creating a new file inside of our commands folder utilities you can call it whatever you want i'm going to call it server info now here we're going to extract the command interaction and the message inbit from the discord.js package so we're going to type cons to open up an object and require.js and now here we can require the command interaction and the message that's all we need from the discord package all right so now we're going to model those exports and the name of the command is going to be server info the description of it's going to be server info you can name it whatever you want and describe it as you like and now we're going to execute and all we need to execute is the interaction and then we're going to grab our parameters for instructions so we're going to type command pretty simple all right so what we're going to be doing is we're going to define dials of course interaction so we're going to get the guide property from the interaction all right and then what we're going to do is we're going to open another const object now you might wonder why didn't we do whatever equals to interaction.guide it's because i want to use the guide as a property itself so and here we're gonna grab whatever we need and we leave this empty for now all right so we're gonna go down a couple more lines and here we're gonna type almost end bit equals to new message embed you can set the color to be whatever you want and now here at the author we're going to set author and here we can type dial.name for example and child icon url and dynamic in case if it's a gif all right so we're going to go to one more line set thumbnail we got that guides icon url and it's also gonna be dynamic very simple all right so now we're gonna start with the fields so we're gonna type dot add fields and we're gonna open up round brackets then um because every field is an object we can open up an object for every field so what we can do is type name and the first field is going to be about general information about the girls we're going to have general for example and the value and then is going to be the backticks so the reason there's a couple of reasons we're using a tactics one of them being the dollar sign and the curly brackets but we're using also the backticks because whenever you basically make a space in your code it's going to be an actual space inside of the embed that's what's cool about this backticks so all right so the first thing in that value is going to be the guy's name so it's going to be guide name and then the created so we're going to basically give information about when the guide was created uh relative to the date right now so what to do that we're going to type this bracket t and now here we're going to type guide dot created at timestamp you can either do that or you can grab the created timestamp from the guide property so you don't have to specify to be guide all right and now we're gonna tap two dots or and then close the bracket pretty simple so far um or actually we're not not even done yet so we're gonna put this inside around brackets and we're going to divide it with 1000 to get the second and then we're going to force it to remove the comma whatever or the dot whatever so we're going to we get a clear number right now for the owner we're gonna type this brackets then add sign and then curly brackets and here we can type we're gonna grab the guide or the owner id from the guide object so we can type owner id and close off the brackets again we indicate a new space and here we're going to type description and it's going to be the guild description so i'm showing you two ways to extract information from an object you can either grab the description from here or you can type guide the description so let's try this out for now all right so now we're done with the first field we're gonna see how our embed looks like and we're gonna see if we get any errors we can correct them now that we have fewer fields so i'm good and now let's uh start the boat all right so here we're gonna type server info like you see here we get the general information tkf community the name of the guide here is the thumbnail and the owner which is me and created two years ago approximately and here we have the description so simple so far now we're going to move over to our the next field so the next field is going to be about the users and then you can add an emoji to if you want if you would like to so it's going to be users and because there is two types of users there's boats and there's members so we're going to filter them out to display the actual numbers so what we can do is we're going to open back takes again a couple of spaces and here we're going to type member and it's going to be and here we're going to filter some members what we're going to do is we're going to grab the members object from the guide so all right so members dot cash dot filter we're going to filter each member and the actual members are going to be the members that are not both so we're going to type estimation mark m dot user dot vote so if the member isn't the boots and here we're going to grab the size so we're going to get the number and now for the box it's the same logic we're gonna copy paste this but we're gonna remove the estimation mark so if the user is bought right so that's it for our users um now let's restart the boat and try our command again server info like you see here we get the users and the member and we can get the total also so what we can do is go down a couple more spaces and we're going to type total and here we can grab the member count property from the guides right here we can type members actually members count member accounts just like this now if we restart again we should see the member count over here so that this is the total all right now let's move to our second or third field which is going to be the channels this is a big feed so what we're going to do is we're going to grab the channel's object from the guide and here we're going to specify the name to be let's add the emoji first of all for example this one why not oops all right so here we're gonna tap chance and the value is gonna be also with tactics all right so the first thing that we're gonna do is we're gonna display the text the amount of text channels that we have so we're gonna here we can type channels dot cache dot filter the same logic that we did here c which is the channel see the type is gonna be equal to guide dot text or underscore text and now for the voice same logic you just copy this paste it here and instead of guide text you can select yield voice pretty simple stuff now for the threads for example let's copy this paste it here instead of gold text is going to be because we have two types of threads we have public or actually three public private and used so let's grab the public right and then we're gonna add the add and sorry and sign and here we're gonna type guild we can copy this copy it here and change the public to private private and the last one was news i think we'll see so let's actually drop this news and here we can put the public pretty simple so far and now for the categories so cut there is we can also copy this paste it here and instead of the guide voice we can choose it to be here guide the category all right now for the stages stages you see guys this is pretty simple we're gonna copy paste it again and instead of got it's gonna be guide dot stage underscore voice or underscore stage under voice and now last but not least use is gonna be i'm gonna copy it again this is like the announcement channels and stuff so where is it in use and that's it so at the end of it we can accept total channels.cash dot size and we forgot to do one thing so we're going to copy that to the sides we're going to test it outside of this round brackets and all of them so we get the actual size not the actual map so now let's write our command again see if we get any errors slash server info like see here we get the text uh the voice threads then two and this might be off by a listed because there's i don't know there's hidden channels like these ones whatever so now we're done with the channels fields we're gonna create another field and this is gonna be for the emojis and stickers so that name is gonna be let's add for example an emoji up here emojis stickers and then the value is going to be same backticks so here we're going to type we're going to filter the emojis that are animated because we have two types of emojis we have animated and static so animated is gonna be equals two and here we can grab the emojis property from the guides let's grab emojis we can type here emojis we're gonna filter each emoji that is actually animated just like this and we're gonna grab the size for the static we're going to do the same thing as same thing static copy paste this and all we need to change is put this exclamation mark behind this e and that should be it now we can put the total actually we need to put the stickers speakers it's going to be stickers sorry let's grab the stickers property or yeah property so stickers just like this stickers dot cash both sides all right and now for the total it's gonna be here it's gonna be stickers dot cash size plus the emojis dots cache those size pretty simple so now let's write our command now that we're done with our field server info actually here stickers static animated and verb so now we're going to move on to the neutral statistics so here we're going to type name and add an emoji and here we're going to type neat row that this takes i always write statistics wrong so if it's wrong don't please don't pull him in the comments so the value is going to be also graphics create a couple of spaces and here we're going to type here and it is going to be actually a guide dot premium premium tier and here we're going to replace because i'm going to show you why so if you type guide those premiums here let's restart the boat so influence can understand tier underscore 3 but that doesn't look nice in the end but so we're going to remove that and it's pretty simple we're going to type dot replace you can replace here underscore with nothing nothing just like this and now if we try it again so slash server info i can see here it's changed to three because we are at tier three all right so now for the boosters or the boost counts uh boosts for example type guide dot premium subscription count very simple and now for the amount of boosters so boosters equals equals to guide dots or actually we're gonna filters for the members so members members dot cash dot filter we're gonna filter and we only get we need the members that premium sends so we're gonna get the size and we are done with our citizen command so now let's go down here at the end of the embed and here we can set a footer saying that at last checked right and then we can set timestamp and now for resortables type slash server info like you see here we have our nature statistics 10 boosters 14 boosts tier 3 and here are the totals so it was a pretty simple command if you also want to display the rules and create a new field and you can set like this for example roles see guide those roles cache the size and you can get the actual size of the rules i place it in their own category now but just to show you how you can do it so sorry for like you see here we have 45 rules now if you see the screen show to the left this is how your command currently will look like on your phone which is a little bit too wacky to fix that kevin fogg find a way to to fix that issue by actually creating an array of value indexes and then zoning these indexes or this string is inside of the array with that with a new line which i will show you in just a second but thank you kevin uh check his github down in the description and now i'm going to show you the fix now to combat that issue all you have to do is change the value of the or the field to be an actual array so um you can create an array basically and inside of that array you're going to place each individual line to its line basically so what we're gonna be doing here is i'm gonna show you an example on one field and then you can change it for the other ones so for example this line is gonna be like this and the same with the others so you're just gonna basically create a list of values all right same with the owner let's remove this extra space this one too all right and then for the last one is going to be the description we're going to place it into its own that get backticks and then here at the end of the day all you need to do is type join and here you're going to join it with with slash n which is an actual space or not space a new line so i'm gonna change it for all of these and then i'm gonna come back to you alright so now that i have done this to all of the fields like you see on on your screen uh so this and now it's that don't join because i forgot to do it here pretty simple uh now let's write the command slash server info and like you see it's completely normal actually looks a little bit more better right now and on the phone it's going to be looking like this so it's much better so thank you guys kevin for finding this out and letting us know and now you learned a new thing so i hope you guys enjoyed this episode i hope to see you in the next
Info
Channel: Lyxcode
Views: 628
Rating: undefined out of 5
Keywords: discord.js, discord, discord bots, discord.js v13, discord.js v13 server info, server info command, serverinfo comma, serverinfo slash command, slash serverinfo, discord.js v13 server info command, lyxcode
Id: eVhCglFpQbM
Channel Id: undefined
Length: 16min 52sec (1012 seconds)
Published: Tue Dec 14 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.