Тёмный

Make Your Own Discord Bot | Commands (NEW 2019) 

CodeLyon
Подписаться 38 тыс.
Просмотров 370 тыс.
50% 1

How to code custom discord commands. Make sure to comment any suggestion for an upcoming video. This is a simple way to create discord bot using discord.js. This tutorial is still in the basic of how to create a discord bot. Subscribe and keep in touch for new videos!
How to get started (First video - Basics): • Make Your Own Discord ...
My gaming channel: / aleshgames
Discord.Js Documentation: discord.js.org...

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1,6 тыс.   
@CodeLyon
@CodeLyon 5 лет назад
New video out lads, How to make custom embeds. Check it out! ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-tQjpv0OO5pA.html
@xicorefps
@xicorefps 5 лет назад
hey bro how can i fix the code when i typing with prefix + word not working when i type only the word without the prefix it works? how can i fix that?
@HundredAcres
@HundredAcres 5 лет назад
Dude you have the best discord bot videos. Seriously. No other people have videos this concise and well done, Thanks a lot!
@SAN925
@SAN925 5 лет назад
Hey i made this code for my bot can i talk to you personally and get the issues solved??(SAN925#9580 is my discord tag please please please invite me i need your help)
@garlandresponses
@garlandresponses 5 лет назад
I did everything and its not work........I do !ping and it does not reply this is my command bot.on('message', message=>{ let args = message.content.substring(PREFIX.length).split(" "); switch(args[0]){ case 'ping': message.reply('pong!'); break; } })
@SAN925
@SAN925 5 лет назад
@@garlandresponses you didn't declare the variable "args" that's what I guess
@Rossilaz58
@Rossilaz58 5 лет назад
How on earth do you only have 53 subs... Now it's 54! You are the best code channel i have seen in ages, across all the languages i have wanted to learn.
@Miraxuu
@Miraxuu 5 лет назад
in two months he has gained more than 950!
@OrenjiMochi
@OrenjiMochi 5 лет назад
@@Miraxuu right?
@kevlar6734
@kevlar6734 5 лет назад
now he has 1,3k, growing fast, man...
@masterfreeze1054
@masterfreeze1054 5 лет назад
Currently at 2.1K!
@envyjoshedits939
@envyjoshedits939 5 лет назад
@@masterfreeze1054 2.4k
@combogfx228
@combogfx228 5 лет назад
2:38 *spells "const" wrong by spelling "cosnt"* "I dont know what happened there, there was an error"
@sketchygfx
@sketchygfx 5 лет назад
IQ of a goldfish. but he did help me
@lowspecghost2403
@lowspecghost2403 5 лет назад
@@sketchygfx xD
@gq69
@gq69 4 года назад
he mispelled it xD, then he fixed it, by spelling *"const"*
@Crow_of_judgement
@Crow_of_judgement 4 года назад
@@sketchygfx well hey, he is still smarter than us for knowing all this lol
@ajojen6346
@ajojen6346 4 года назад
It was 4:14 AM. He was probably tired.
@zerki-coding
@zerki-coding 4 года назад
Me: Coding the first command then coding the reply to just 1 message Bot: Reply with 10 messages Me: Am I a joke to you?
@loop5720
@loop5720 4 года назад
Me: Coding the first command then coding the reply to just 34 messages Bot: **Replies with 69 Messages** Me: This has gone more than Mario sexual.
@zerki-coding
@zerki-coding 4 года назад
@@loop5720 oh shit
@tidyen
@tidyen 4 года назад
That's considered a botception. Put " if(message.author.bot) return;" code outside the event.
@maxwell9843
@maxwell9843 4 года назад
@@tidyen thanks, but that just gives me if(message.author.bot) return; ^ ReferenceError: message is not defined
@nightbringer6066
@nightbringer6066 4 года назад
happens to me too :(
@masterhacker-5883
@masterhacker-5883 4 года назад
My mom:Dinners ready me:i'll be right there Lyon: thanks for watching me;.-.
@KingJacob105
@KingJacob105 4 года назад
What..?
@cashess6912
@cashess6912 4 года назад
@@KingJacob105 ikr lmfao r/youngpeopleyoutube?
@KingJacob105
@KingJacob105 4 года назад
@@cashess6912 oh hecc yeah
@iceojayyy6373
@iceojayyy6373 3 года назад
😐
@SDFTDusername
@SDFTDusername 4 года назад
this is really helpfull! tip: you can also make a notepad then type: cd Desktop cd discord bot node . and then save it as a .bat file and that is faster!
@Trashyy
@Trashyy 4 года назад
Make a tutorial if possible please and thanks
@SDFTDusername
@SDFTDusername 4 года назад
;-;
@SDFTDusername
@SDFTDusername 4 года назад
more easier. make an notepad and type node . then save it as a bat. BUT put it in the discord bot folder
@_yanchfibrensh7211
@_yanchfibrensh7211 4 года назад
Did you know there is a way to instantly access to the command prompt through folder? Shift right click on any place while in a folder and there will having a selection to let you open the command prompt directly pointed to your folder
@ayk4y827
@ayk4y827 4 года назад
well no
@IDcLuc
@IDcLuc 4 года назад
You need to use message.channel.send, since .sendMessage is replaced by .send. Edit: It depends on which *discord.js* version you use.
@wildcard3383
@wildcard3383 4 года назад
where?
@IDcLuc
@IDcLuc 4 года назад
@@wildcard3383 when you make a command, you do message.channel.sendMessage, right? You need to use message.channel.send instead
@Griizz_floppy
@Griizz_floppy 4 года назад
Thought I was dumb or something, thats the fix.
@fgdx
@fgdx 4 года назад
what to replace rather than message.channel.fetchMessage ? @LUCATIVIOMAD2 Official
@IDcLuc
@IDcLuc 4 года назад
@@fgdx you can use msg.channel.send
@_eagleofsuger_4631
@_eagleofsuger_4631 4 года назад
*turns on captions* "ladies in German"
@Lenny-nl1ce
@Lenny-nl1ce 4 года назад
Frauen
@ayycorn762
@ayycorn762 5 лет назад
I am making a bot (started today) and just finished the Basics video. My man, You are a godsend. It is beyond helpful.
@YoUZClan
@YoUZClan 5 лет назад
If you are having trouble with the prefix command just save before you do it and it should work
@tazbid8489
@tazbid8489 5 лет назад
can you help me? it says Discord.client is not a constructor
@RedCoconuts
@RedCoconuts 4 года назад
I had an issue where my bot would react to any prefix even though I set a specific prefix. Fixed this by adding if (!message.content.startsWith(prefix)) return; just below the let args = message.content.substring(prefix.length).split(" ");
@mentalost
@mentalost 4 года назад
Worked ! Thank you alot.
@driz6353
@driz6353 4 года назад
Thanks, it work!
@Kevin18
@Kevin18 4 года назад
doesnt work for me :( vant get to work
@JohnPaul-jy2xw
@JohnPaul-jy2xw 4 года назад
ReferenceError: message is not defined
@puni6661
@puni6661 4 года назад
@@JohnPaul-jy2xw same problem i had, I don't understand who is this error...f""
@vFSxMoPh3Dz
@vFSxMoPh3Dz 5 лет назад
Loved the video, thanks for kickstarting my bot making adventures! Just to note; there is nothing in the code written in the video to actually verify the prefix characters are the same as the ones stored in the prefix const. This is really important as you could literally use any character (or combination of if you're using multiple characters in your prefix) and your command will run. I added this bit of code to run right at the start that will just simply verify and escape if its not the same: // Check prefix is valid if (message.content.substring(0,PREFIX.length) != PREFIX) return;
@axthny
@axthny 5 лет назад
you dont need that
@vFSxMoPh3Dz
@vFSxMoPh3Dz 5 лет назад
@@axthny It would be considered a serious flaw in your code if the bot responsded when called with the wrong prefix.
@Milan-uz1nc
@Milan-uz1nc 5 лет назад
@@vFSxMoPh3Dz Where to put that piece of code??>
@vFSxMoPh3Dz
@vFSxMoPh3Dz 5 лет назад
@@Milan-uz1nc The logical place would be when the bot initially checks a message (after the bot.on). Hope this helps. // Server Commands bot.on('message', msg=>{ // Check prefix is valid if (msg.content.substring(0,prefix.length) != prefix) return;
@thisislame2207
@thisislame2207 5 лет назад
@@vFSxMoPh3Dz Extremely helpful! Thank you very much!
@bigboi3957
@bigboi3957 4 года назад
When adding the code 'message.channel.sendMessage('pong!')', it wont work in 2020, remove the "Message" next to pong and it shall work!
@Dragonrage1oo1
@Dragonrage1oo1 4 года назад
weird because it worked fine for me.
@kennyv1854
@kennyv1854 4 года назад
OMG thanks so much
@potatoman4548
@potatoman4548 4 года назад
@@Dragonrage1oo1 because you have v11 of discord.js
@duckgoose_
@duckgoose_ 4 года назад
wow thanks
@julianatkinson5142
@julianatkinson5142 4 года назад
Thanks you, I was stuck on this for a long time
@bulldozer0537
@bulldozer0537 5 лет назад
you should make a level bot tutorial... Like please
@sebikutz7346
@sebikutz7346 5 лет назад
... You don't need to create a level bot if you have MEE6
@bulldozer0537
@bulldozer0537 5 лет назад
Well what if I want to have a bot that has a leveling system so I don't have to go through all the truble of setting up MEE6 and I want people to use my bot.
@pre699
@pre699 4 года назад
sproutville mee6 requires premium now, so for people who don’t have premium, mee6 won’t assign level roles
@tomato-v8x
@tomato-v8x 4 года назад
sproutville mee6 is shit now
@pocyfstuff2488
@pocyfstuff2488 4 года назад
Mee6 is free for leveling systems. Also, I'd say setting up mee6 is less troublesome than creating a bot that does leveling systems.
@roombster
@roombster 4 года назад
Hey! If you guys are on the newer version of Visual Studio Code, you have to save the command before turning your bot back on and using the command.
@hansrouwenhorst1420
@hansrouwenhorst1420 4 года назад
How do you turn the bot off Ctrl + C doesn't work for me
@SuperPhantomUser
@SuperPhantomUser 4 года назад
Thank you so much it kept showing the same error (typo) even though I fixed it over and over.
@kireristomanov233
@kireristomanov233 5 лет назад
Can you make a bot that posts an image from an online website. This image changes. And I wanna do it where it sends that image at a specific time.
@RhozetaVODS
@RhozetaVODS 4 года назад
you might have to make a bot for that website, like Reddit API if you want to automatically steal memes
@AAAqua
@AAAqua 5 лет назад
Hello ! I am new to your channel and I actually love the contact you make. I would like to see more of your contact. Don’t forget don’t work too hard. Or maybe the hard drive might fail.
@StackRunItUp
@StackRunItUp 4 года назад
On second thought... I don’t want to make my own discord
@ajojen6346
@ajojen6346 4 года назад
It's a long process, but well worth it.
@cozyboy9730
@cozyboy9730 5 лет назад
Great Content. However you should implement as "message.content.startsWith(PREFIX + args[0])". Since PREFIX.length is always equal to 1 in this case, it will work with any prefix of length 1, not just "!" as intended.
@pixel8122
@pixel8122 5 лет назад
Thank you so much! How would I go about if I was wanting to make the prefix something that has a length of 2, such as p!
@cozyboy9730
@cozyboy9730 5 лет назад
@@pixel8122 Just change the variable to "const PREFIX = "p!". Then "PREFIX.length" will now equal 2. For example, // define PREFIX const PREFIX = "p!" // add an if statement to capture any message with the prefix if (msg.content.startsWith(PREFIX)) { // then assign the args just like before, PREFIX.length will be 2 here let args = msg.content.substring(PREFIX.length).split(" "); // rest of code switch(args[0]) { case .... } }
@danstewart1870
@danstewart1870 5 лет назад
sorry im kind of confused... where do i implement this? Is it after 'let.args =' or...
@joryjuky3561
@joryjuky3561 5 лет назад
Um, just a note, for current watchers. Instead of .sendMessage, just use .send
@kazeexe8685
@kazeexe8685 4 года назад
Thanks mate, Really Help
@a.man38
@a.man38 5 лет назад
Hey man, you are great at coding and I know you will have heard that a lot, but you're a great RU-vidr! you aren't condescending at all, and are very helpful with trouble shooting, you've earnt a sub!
@mlndev
@mlndev 5 лет назад
Thanks for the help!How did you get this cool wallpaper?
@CodeLyon
@CodeLyon 5 лет назад
Wallpaper Engine on Steam :)
@sirarchibald
@sirarchibald 4 года назад
This is an old video, but its the best guide out there on how to make a bot. I have a bit of an issue though. When I Control + C the bot in my terminal, the bot stays online, so when I reactivate it a couple of seconds later, the code changes haven't taken effect. Do bots usually turn off this slowly, or am I doing something wrong?
@thetecno5800
@thetecno5800 4 года назад
I trash the terminal and then start a new one
@lowspecghost2403
@lowspecghost2403 5 лет назад
Was: Aleshgames Now: CodeLyon
@TheChangospace
@TheChangospace 5 лет назад
My respects....this guy knows coding way more than my peasant ass....i'm barely knowledgeable enough to give someone admin privileges
@ColinNieman
@ColinNieman 4 года назад
i cant get commands when i type it in discord is says nothing
@jellyjumper
@jellyjumper 4 года назад
same
@dinlvaj
@dinlvaj 4 года назад
i did 2 messages and then it stopped working
@SexyPrisoner21
@SexyPrisoner21 4 года назад
same the !ping just dosent do anything
@NeymarLovers
@NeymarLovers 5 лет назад
The bot is never coming onlie....please help
@cruuuuust
@cruuuuust 5 лет назад
Neymar Lovers he ded HAHAHA sorry
@lunatick2042
@lunatick2042 5 лет назад
He said everything I wanted to do when I was thinking it!! You just got a sub!!!
@fireandbombs12
@fireandbombs12 4 года назад
Wow, this is actually awesome! This is the first time that I feel like I'm doing something real with programming. Thank you, very cool!
@Rossilaz58
@Rossilaz58 5 лет назад
Can you tell us how to make it so only admins can use the clear command?
@gameramante
@gameramante 5 лет назад
I'm not sure if it would work, but you maybe could create a json file and add all the administrators of your server, then, every time a person uses the command clear make the bot check if the user is in the json list.
@gameramante
@gameramante 5 лет назад
P.S: There might be easier ways to do that, I don't make bots using discord.js so i'm not sure, I use Python.
@joxdv
@joxdv 5 лет назад
Gameramante not even close, but here is how you would do it . if(!message.member.hasPermission("Administrator ")) return message.reply("you Don’t have enough permissions.");
@gameramante
@gameramante 5 лет назад
@@joxdv Oh dang, i didn't know that, well thanks i'm still learning JS
@joxdv
@joxdv 5 лет назад
Gameramante you good bro, no worry’s
@godzillakingofthemonsters6996
@godzillakingofthemonsters6996 4 года назад
it ignores the fact that I have a prefix and can only send pong when I write "ping" without a prefix, if I use my prefix it won't send
@cooldwaterstudio2470
@cooldwaterstudio2470 4 года назад
whatsup with that? same with me
@icespadesss9173
@icespadesss9173 4 года назад
The second line of code under the bot.on(message) that says (PREFIX.length) is important. Also the prefix const is important that you have at least one prefix in the string, or in the ' '
@adiisbest6051
@adiisbest6051 4 года назад
I did that and it still does not work for me
@Luciffrrr
@Luciffrrr 4 года назад
do one thing , reinstall the files from cmd and regenrate the bot token. and do the prefix thing again.
@seji5972
@seji5972 5 лет назад
Thanks for the tutorial but you literally didn't do anything with your prefix, with that code you could type any character and it would still run your commands.
@DinoDonutMan
@DinoDonutMan 5 лет назад
i know right, put if(!message.content.startsWith(prefix)) return; above let args to get it to work.
@ahnet.69
@ahnet.69 4 года назад
@@Gold_74 it worked for me the if(!message.content.startsWith(prefix)) return;
@skzafir721
@skzafir721 4 года назад
@@Gold_74 Thanks bro.
@jenniferl1154
@jenniferl1154 4 года назад
@@DinoDonutMan Hey, so when I did that I can still do ping without any prefix and it works. Any fix for that?
@edancazakov
@edancazakov 4 года назад
@@jenniferl1154 paste if(!message.content.startsWith(PREFIX)) return; under bot.on('message', message=>{
@FusionTerror
@FusionTerror 4 года назад
For anyone having issues with his code it is most likely because you are using v12 of discord.js for anyone new, when you used "npm install discord.js" it installed the latest version which is version v12. Code Lyon uses version v11 in these videos. The difference is that some of the commands changed in the update. To convert old code to new code so you don't get any errors you can read here (discordjs.guide/additional-info/changes-in-v12.html) or you can reinstall discord.js and this time use "npm install discord.js@11.6.3" to get v11 of discord.js so that you can follow along with his tutorials and have no errors.
@magpie325
@magpie325 4 года назад
If you are having issues with: message.channel.sendMessage('pong!') try: message.channel.send('pong!')
@mikechiaramonte2225
@mikechiaramonte2225 4 года назад
is there a reason that line works where as message.channel.sendmessage doesnt?
@magpie325
@magpie325 4 года назад
@@mikechiaramonte2225 Probably versions, as this video was made longer ago.
@player210
@player210 4 года назад
Thanks!
@magpie325
@magpie325 4 года назад
@@player210 Anytime. Reply if you have any further questions :D
@magpie325
@magpie325 4 года назад
@Arsène Taranne lmao thats what I was saying lol click "read more"
@mcbride967
@mcbride967 5 лет назад
Love these videos. having a ton of fun coding a bot for my guilds discord! :D
@guy-dev
@guy-dev 4 года назад
You need to make a 2020 version for PERMISSIONS, the old method doesn't work now.
@jameskim6159
@jameskim6159 3 года назад
you have to give your bot admin perms
@abdulrahmanlitp4941
@abdulrahmanlitp4941 3 года назад
I'm commenting for more people to watch this, much appreciating
@april_15
@april_15 4 года назад
We need a bot video on how to make a logs channel and a reaction roles thing. like so he sees this
@CJ_meow
@CJ_meow 3 года назад
i think dyno or mee6 can do that its a waste of time to make a bot only for that i mean you probably figured out how to make one or already using dyno or mee6 (i cant remember wich one has logs) since it has been 8 months
@dinlvaj
@dinlvaj 4 года назад
instructions unclear, started a bot uprising
@TheCreeperyXYZ
@TheCreeperyXYZ 5 лет назад
When i type command, bot doesn't respond at all :(
@LucasOliveira-he4tk
@LucasOliveira-he4tk 5 лет назад
same it happened to me too
@PatatjeMC
@PatatjeMC 5 лет назад
same
@ПоповићЛука
@ПоповићЛука 5 лет назад
try looking for mistakes in you code. I for example messed up at line 14 where i wrote PREFIX.lenght instead of length. Cheers
@mobaius6479
@mobaius6479 4 года назад
Its the 2nd video I'm watching, and I want you to know how much I appreciate you, and what you are doing to help people out. This is not an obvious thing to do. Thank you :)
@lasaveloy
@lasaveloy 5 лет назад
Can you show how to create channels/categories, with names, permissions, etc. Also getting a user's message. So say they say !embed "text text text" the "text text text" part will be in that embed.
@shemarboyce8714
@shemarboyce8714 4 года назад
I have a question about the ping command I did exactly what you did here but only kept the ping command separately, I was wondering how can you get the ping command to show the ping number for example when you do said prefix .ping and the responds pong! what is the coding so that when you do the ping command it will say pinging... for a split second and it will say pong! `107ms` how can I get the ping command to do this?
@jeidenae
@jeidenae 5 лет назад
Thanks! Also, how do i make it that the response of the bot is random? (Like MEE6)
@axilerate3474
@axilerate3474 4 года назад
try using the math.Random function
@spunkmc482
@spunkmc482 4 года назад
how the frick did you record something this good at 4 AM?
@facer1010
@facer1010 5 лет назад
Umm it's not responding to any of my commands also in the last video i said HELLO, it didn't respond... idk i checked 5 times your and mine script, they both are the same, there are no mistakes on the output, idk:( i've tried saving the script the again using node . to start it, it never works :(
@LightCreations
@LightCreations 5 лет назад
same
@fighter2547
@fighter2547 5 лет назад
Hello! If you are on a mac, press Command+S. If you are on PC, press CTRL+S. Then, press CTRL+~ and type "node ." then it should work!
@hugoboston
@hugoboston 5 лет назад
Fighter my bot is online but when I type the stuff it doesn’t respond
@popflorian3119
@popflorian3119 5 лет назад
@@hugoboston same
@Milan-uz1nc
@Milan-uz1nc 5 лет назад
@@hugoboston Do you have your script open if not open it and type node . (You hopefully know where to if not open the window thingy with ctrl+` or for mac command+` Idk sure bout mac tho) gl if it does not work contact me and ill help you through it Best wishes milan
@discjrolli
@discjrolli 4 года назад
I LOVED THIS SERVER VERY INTERESTING TO LEARN THE CODINGS FROM THIS CHANNEL U WILL GET MIRE SUBS CONGRATULATIONS CODELYON BRO
@willkos814
@willkos814 4 года назад
if I do !ping and ! is my prefix and then I do &ping it responds??
@fabriziorasore5353
@fabriziorasore5353 4 года назад
nope
@maide4157
@maide4157 4 года назад
@@fabriziorasore5353 it actually does
@OvenproofMeteor
@OvenproofMeteor 4 года назад
@Suiko Waterlie can you elaborate, i'm confused
@vilmer7514
@vilmer7514 4 года назад
​@Leire Killough The fix is to add this: "if(message.content.substring(0, pre.length) == pre)" right before the switch. Then you have to put all of the switch code in curly brackets{}.
@vilmer7514
@vilmer7514 4 года назад
@@OvenproofMeteor The fix is to add this: "if(message.content.substring(0, pre.length) == pre)" right before the switch. Then you have to put all of the switch code in curly brackets{}.
@phonixtheamazing8780
@phonixtheamazing8780 5 лет назад
Can't wait for the next video on the permissions! Thanks for all the help so far!
@parmo5529
@parmo5529 5 лет назад
I did everything just like you Said it but it want respons when do the command
@Sovxly
@Sovxly 4 года назад
same
@ogi_nsc
@ogi_nsc 4 года назад
same
@itsmedeer
@itsmedeer 4 года назад
same
@user-lx5pl3rx6h
@user-lx5pl3rx6h 4 года назад
7:45 " mesasge.chanel " yo thats some epic coding ngl xd (no offence tho my man this helped me a lot)
@carverlocal7304
@carverlocal7304 4 года назад
A couple things 1) None Of My Commands Work. Doesn't Matter If I'm Pinging My Bot, Pinging With Prefix, Just Prefix, Or Just The Command No Prefix 2)My Bot Keeps Going Offline Pls Help Me
@dragz9370
@dragz9370 4 года назад
Trench Banditos Entertainment same
@dragz9370
@dragz9370 4 года назад
Your bot is going offline cus u need a hoster
@xavia7933
@xavia7933 4 года назад
ECDZ unsuspended account try saving then trying again
@flashstryker4936
@flashstryker4936 4 года назад
please go back to part 1 of making your bot and look carefully
@s0ul352
@s0ul352 3 года назад
If anyone is watching this in 2020+, have note that "message.channel.sendMessage('pong!)" wont work, now it was updated so you have to write "message.channel.send(''pong!)" instead.
@Shanatsumomo
@Shanatsumomo 5 лет назад
I have this problem where my prefix doesn't work. It replies without using a prefix. Do you know how to solve that? :/
@RandomGuy-dv7ju
@RandomGuy-dv7ju 5 лет назад
yea me too
@willkos814
@willkos814 4 года назад
@Floopatron I tried that and it still doesnt work correctly
@unrealkatie8217
@unrealkatie8217 4 года назад
This is amazing! Easy to understand, and easy to follow!
@marshallmickells
@marshallmickells 4 года назад
I'd be interested to learning how to create a bot used for running tournaments for some games we play on a Discord sever.
@lmao.1861
@lmao.1861 5 лет назад
Incredible how good you are at coding jeez, teach me Master.
@Nygma-
@Nygma- 4 года назад
how to make a code that will clear the chat and say: (x) sentences cleared by (user)?
@XLegenDarkness
@XLegenDarkness 4 года назад
you will probably find the command list if you search up "how to purge chat with a discord bot" or something
@hulk-.-
@hulk-.- 4 года назад
bot.on('message', message=>{ let args = message.content.substring().split(" "); switch(args[0]){ case '!clear': if(!args[1]) return message.reply('Error. Please specify how much messages you want to delete.') //this sends an error to user if you only typed !clear. .then(sentMessage => sentMessage.delete({timeout: 5000})); //this deletes the message after 5 seconds. else if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply('You don't have the power to use this command.') //this sends a message if you dont have the "manage_messages" permission. .then(sentMessage => sentMessage.delete({timeout: 5000})); //this deletes the message after 5 seconds. message.channel.bulkDelete(args[1]); //this deletes the messages. message.channel.send(args[1] + ` Messages has been cleared by ${member}`) .then(sentMessage => sentMessage.delete({timeout: 5000})); //this deletes the message after 5 seconds. break; }} since i couldnt handle with the prefix i used the '!' in the case XD the ${member} pings the user, so if you dont want to ping them, only want to type their username, you can use: message.channel.bulkDelete(args[1]); message.channel.send(args[1] + ` Messages has been cleared by ` + message.author.username) .then(sentMessage => sentMessage.delete({timeout: 5000}));
@Nygma-
@Nygma- 4 года назад
@@hulk-.- thankss!!
@hulk-.-
@hulk-.- 4 года назад
@@Nygma- btw there is an issue that i couldn't fix. when you type !clear asd, it sends asd messages has been cleared by (sender). so, it accepts the 'asd' as the argument. idk how to fix that, you have to look it up :/ (i couldn't find it, so if you find it can you message me through dc? (CreeplyCreep#2573)
@hulk-.-
@hulk-.- 4 года назад
@@Nygma- found the solution for !clear asd. Add this after the second 'if' statement: else if(args[1] != Number) return message.reply('Error. Please type a number.') .then(sentMessage => sentMessage.delete({timeout: 5000}));
@sirrooster1541
@sirrooster1541 4 года назад
Thanks for the tutorials man! These tuts helped me out a lot :) - Hope you make more in the future!
@user-dm5su4gw2u
@user-dm5su4gw2u 4 года назад
can anyone HELP ME OUT PLEASE when i write args it says it's not defined
@user-oo9cp6wv3u
@user-oo9cp6wv3u 4 года назад
@IMHYR0X how do you make it a keyword?
@ScriptoSwift
@ScriptoSwift 4 года назад
The Prefix can be anything Prefix for me. I want it to be only doing one Prefix, not all of the Prefixes.
@halfpixelstudios99
@halfpixelstudios99 4 года назад
bot.on('message', message => { if (!message.content.startsWith(PREFIX)) return; let args = message.content.substring(PREFIX.length).split(" ");
@ScriptoSwift
@ScriptoSwift 4 года назад
CIA Thanks!
@Dani-vy1lx
@Dani-vy1lx 4 года назад
"control + c to close it" * clicks x
@eacho3880
@eacho3880 4 года назад
For the Hello. You can change it to a prefix for example do .Hello and it will change.
@DubCentral1
@DubCentral1 4 года назад
Hi, does anyone know why i get the error on the bot.login(token); ? It says "unexpected end of input".
@OvenproofMeteor
@OvenproofMeteor 4 года назад
make sure when grabbing your token from discord that you grab itf from the bot section and not the general section, i made this mistake i would have never noticed if i didn't rewatch the video and redo each step. You could have all your code perfect but you could never account for your token just being the wrong token
@babypriyanshu3473
@babypriyanshu3473 5 лет назад
Your videos helped me a lot to fix my programs ^o^ Best wishes But Can you make a video on how to like if someone has written wrong cmd but with prefix, how the bot sould react >:O that would be a great help :D
@LethargicKitty
@LethargicKitty 5 лет назад
I have set my bot's PREFIX as '-' but it doesn't care what the PREFIX is. It sees "-botinfo" and "dbotinfo" the same. You can replace the "d" with any other character on the keyboard, too, it will still do the command. What did I do wrong?
@LethargicKitty
@LethargicKitty 5 лет назад
i fixed it
@kwanlitzia
@kwanlitzia 5 лет назад
@@LethargicKitty how???
@LethargicKitty
@LethargicKitty 5 лет назад
@@kwanlitzia ya have to check to make sure it is the prefix with an if put this if(message.content.startsWith('-') == false) return cdn.discordapp.com/attachments/433748436609662996/576820187408629762/unknown.png
@kwanlitzia
@kwanlitzia 5 лет назад
@@LethargicKitty thank you do much bro!
@LethargicKitty
@LethargicKitty 5 лет назад
@@kwanlitzia No problem! I should probably clarify that the '-' is what i chose as my prefix
@ebayflights6880
@ebayflights6880 4 года назад
can u make a discord advertising bot like one that goes to ppls dms and invite them to ur discord server
@jayexx
@jayexx 4 года назад
bot like that get deleted from discord so dont bother trying to make one
@凁
@凁 4 года назад
bot like that get deleted from discord so dont bother trying to make one x2
@hadiaxh
@hadiaxh 5 лет назад
hey, its me again, so everytime I try adding a new commad, this red little line shows up and the word case doesn't turn purple. any idea on how to fix it?
@Outflown
@Outflown 4 года назад
heres what the script supposed to look like: const Discord = require('discord.js'); const bot = new Discord.Client(); const PREVIX = "."; const token = 'insert token here'; bot.on('message', message=> { let args = message.content.substring(PREVIX.length).split(" "); switch(args[0]){ case 'creators': message.channel.sendMessage('JoshuaScripts#0122 is the only creator.') break; case 'everyone': message.channel.sendMessage('MAYBE not.') break; case 'invite': message.channel.sendMessage('discordapp.com/oauth2/authorize?client_id=523551992279203840&scope=bot&permissions=8') break; } }) ["no"]; bot.login(token)
@godzillakingofthemonsters6996
@godzillakingofthemonsters6996 4 года назад
@@Outflown previx?
@godzillakingofthemonsters6996
@godzillakingofthemonsters6996 4 года назад
me too it's confusing as hell
@JITSoftware
@JITSoftware 4 года назад
For those who just popped along, the documentation has changed, if you want to have it send a message make sure to have it msg.channel.send(string) Make sure to check documentation for discord api regularly just in case they change it again and my comment becomes outdated
@mozaary
@mozaary 4 года назад
oh that explains, thank you so much!
@AriLAng11
@AriLAng11 4 года назад
You're amazing, thanks!
@pillow.98
@pillow.98 5 лет назад
this might be a goofy question but is it possible to get the bot to respond to a phrase rather than just a word? im trying to make a bot u can more or less have a conversation with based on commands and idk how to make it respond to more than one word as the command, if that makes sense
@Waverly_ppl
@Waverly_ppl 5 лет назад
Yes, someone on discord name BradGames made a bot "Abuse" and it can have conversations with people.
@gabinotpolkas3895
@gabinotpolkas3895 4 года назад
this is so interesting! thank you so much for this tutorials
@rainoftime37
@rainoftime37 5 лет назад
Does anyone know how to make the bot respond with a random message selected from a list? If you do please let me know!! Thank you!
@hedgehogmind3186
@hedgehogmind3186 5 лет назад
I think the easiest is to use the Math.random() function followed by if statements that reply with text you want to send if the variable is in a certain range. Do some research on if statements and variables. If you want the list to be part of a user input thats a little difficult.
@himeoftwili
@himeoftwili 4 года назад
Awesome tutorial. Very helpful. Will you be doing anything on randomising bot replies?
@ogi_nsc
@ogi_nsc 4 года назад
My bot wont reply, can u help me´?
@scarakaozzy
@scarakaozzy 4 года назад
the bot isnt replying in chat when i say ping with my prefix
@Taco_Melon
@Taco_Melon 4 года назад
you have to save everytime before you said node .
@itsmeteo3444
@itsmeteo3444 4 года назад
I had the same issue, in the case 'ping' command, instead type case PREFIX + 'ping' hope this fixes it for ya ; )
@luxus3693
@luxus3693 4 года назад
Instead of .sendMessage just put .send
@astrix8812
@astrix8812 4 года назад
I am not even building a bot in JS but i still liked it. This video is awesome!
@starzapbg3014
@starzapbg3014 5 лет назад
How to fix the prefix beacause it doesn't work???
@starzapbg3014
@starzapbg3014 5 лет назад
I already fixedit somehow but i dont remember what i did😥
@antoineholliday7631
@antoineholliday7631 5 лет назад
Help, I can get it to work
@starzapbg3014
@starzapbg3014 5 лет назад
@@antoineholliday7631 thanks but i figured it out its been a bit of time as you see
@antoineholliday7631
@antoineholliday7631 5 лет назад
@@starzapbg3014 I meant to say was, " Help, I CAN'T get it to work". If you know, please help me
@starzapbg3014
@starzapbg3014 5 лет назад
@@antoineholliday7631 Oh well then i am sorry but i have no f ing idea what was that that i did. Afterall its been two months or more
@sullymlg9785
@sullymlg9785 4 года назад
I swear these tutorials could make me learn Java! - It's super similar to C# so I have a bit of a head start
@exec_tioner
@exec_tioner 4 года назад
i wanna learn lua for roblxo
@Maxb0tbeep
@Maxb0tbeep 4 года назад
it is just send instead of sendMessage now, btw
@retnuhretnuh
@retnuhretnuh 4 года назад
Thank you, I was very confused.
@casualcasualty6378
@casualcasualty6378 4 года назад
If you are looking for a easy rank giver on discord servers just search up Carl bot watch the tutorial and there you go
@thexerothermic2058
@thexerothermic2058 5 лет назад
2:25 - 2:42 cosnt
@milas6487
@milas6487 4 года назад
how do you not have at least 100k subs? these tutorials are awesome
@ogi_nsc
@ogi_nsc 4 года назад
My bot wont reply, can u help me´?
@reflex_yt7184
@reflex_yt7184 5 лет назад
i did another prefix but the clear command didn't want to work
@binbows
@binbows 5 лет назад
SyntaxError: missing ) after argument list at Module._compile (internal/modules/cjs/loader.js:721:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:829:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3 I get this error when i try to start the bot Please help
@cruuuuust
@cruuuuust 5 лет назад
binbows did u save it
@basementvlogs711
@basementvlogs711 5 лет назад
i typed ping and another bot responded lol
@FelixAdler
@FelixAdler 5 лет назад
This comment makes me smile and laugh. Thank you for sharing this!
@nari5515
@nari5515 4 года назад
Keep going 🙂❤️
@mateyx1305
@mateyx1305 5 лет назад
the prefix wont work... whenever i use $ as my prefix it works but other symbols work too such as !, @, #, %, ^, & HELP PLEASE
@dylansingh3297
@dylansingh3297 5 лет назад
the same thing with me, idk what to do
@ericng3673
@ericng3673 5 лет назад
Bcz he is using PREFIX.length which reads the prefix length...not the prefix itself
@antoineholliday7631
@antoineholliday7631 5 лет назад
@@ericng3673 So how do I get the prefix to work
@theinvertedpineapple942
@theinvertedpineapple942 5 лет назад
Galaxy Watch I can’t get it to work either!
@hikahime3152
@hikahime3152 5 лет назад
bot.on('message', msg=>{ let args = message.content.substring(PREFIX.length).split(" "); switch(args[0]){ case 'ping': message.reply('pong!'); break; } })
@danz8520
@danz8520 5 лет назад
Can you use an enter key on commands? For example Command: Ping Response: Pong! Prong!
@DRACORIX
@DRACORIX 4 года назад
in the future we have a pandemic named "covid-19"
@leovillaz
@leovillaz 4 года назад
Nice video Lyon... I´m here to learn to make a bot for Destiny 2 :D heheheheh and make grids for raids or other actvities
@hansrouwenhorst1420
@hansrouwenhorst1420 4 года назад
How can we turn off the bot, if I do Ctrl + C it won't turn off.
@yA-iq5iw
@yA-iq5iw 4 года назад
make sure you click in the terminal and then do ctrl + c
@nicololabrijn
@nicololabrijn 3 года назад
i like your city background verry much! Were can i find it? And nice video's btw!
@maxtebrake
@maxtebrake 3 года назад
wallpaper engine
@mentosiak6513
@mentosiak6513 5 лет назад
bot doesn't reply at all even though he is running and I followed all instructions
@jamesbarthomoly1283
@jamesbarthomoly1283 5 лет назад
Mentosiak same
@jamesbarthomoly1283
@jamesbarthomoly1283 5 лет назад
Skuffies Yes, How do I grt my settings.
@jamesbarthomoly1283
@jamesbarthomoly1283 5 лет назад
Mentosiak sure
@jamesbarthomoly1283
@jamesbarthomoly1283 5 лет назад
Wait for all the files?
@jamesbarthomoly1283
@jamesbarthomoly1283 5 лет назад
Well if you want
@Z3R090210
@Z3R090210 4 года назад
Videos have been super HELPFUL. Thank You.
@IceKingFlash
@IceKingFlash 5 лет назад
Why make the video at 4AM OOF
@corejourneydotorg3166
@corejourneydotorg3166 4 года назад
For those who also have problems with !clear go to your discord application then click OAuth2, under scopes check bot and under permissions administrator and use that invite link.
@GamingWithDoggy
@GamingWithDoggy 4 года назад
Me realizing this is lua script My brain : yes
@pHaace
@pHaace 4 года назад
Hey do you cover makiing each command a js file of their own in a commands folder? You stopping to explain what your doing is best part of this tutorial as i thought learning javascript by discord would be easier but all other tutorials want you to know js already but you're making things clear as to what they are and what the line of code is actually doing.
@oldaccount5994
@oldaccount5994 4 года назад
Every time I type “else” it says “Declaration or statement expected.” What does this mean?
@gionhatz3783
@gionhatz3783 4 года назад
i get that too budy
@matts5803
@matts5803 4 года назад
I'm having an issue where no matter what number I put after clear, it still sends the error message. Is anyone else having this issue?
@finzip4578
@finzip4578 4 года назад
have you solved it?
@matts5803
@matts5803 4 года назад
@@finzip4578 Yep. I'm pretty sure this is all the code you need, but I forget, I've slept on my bot project for a while now. case 'clear': if(!args[1]) return message.reply ('Error, define # of messages.') message.channel.bulkDelete(args[1]); break;
@novatv5508
@novatv5508 4 года назад
@@matts5803 You know how it works with custom prefixes ?
@skiify1
@skiify1 5 лет назад
Music Bot
Далее