Тёмный

How to make a Discord Music Bot • Discord.js (2022) 

Подписаться
Просмотров 104 тыс.
% 2 335

Today I walk you through the step by step process of building your own Discord Music Bot from scratch. We cover a variety of different commands and features including
- a play command that can load single songs, playlists, or search generally from the internet.
- a paginated queue command
- pause/resume commands
- info command with a progress bar
npm packages installation
npm i dotenv discord.js discord-player @discordjs/voice @discordjs/rest @discordjs/opus @discordjs/builders
You will also need to install ffmpeg in order for the bot to stream music. Find the relevant information here: ffmpeg.org/download.html
Timestamps
0:00 Intro
0:50 Setup code environment
1:28 Start coding the bot
4:32 Slash command file loader
7:45 Deploying Slash commands
9:58 Slash command handler
12:31 /play
24:59 /queue
33:54 /quit
35:38 /shuffle
36:32 /info
38:43 /resume /pause
39:52 /skip
41:07 /skipto
43:35 Demo
46:20 Outro
🔗 Links
Source Code: github.com/3chospirits/discord-music-bot/tree/a260d1eb43a974ea232c603c93b0e1f40647ae68
Discord Server: discord.niconiconii.xyz

Наука

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

 

21 фев 2022

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 389   
@Niconiconii
@Niconiconii 2 года назад
This video took me probably a total of like 20 hours to create, so it would be greatly appreciated if you could leave a like if you found it helpful! Thank you for watching :)
@avgamer8050
@avgamer8050 2 года назад
@Niconiconii hey niconiconii will you make a video on how to keep a bot online 24/7 pls as when I close the VS CODE (where I have written the code) the bot automatically gets offline...
@avgamer8050
@avgamer8050 2 года назад
Pls reply 😭
@Gort-ft4ey
@Gort-ft4ey 2 года назад
@@avgamer8050 he has given sites that'll do that for you
@bevusan6879
@bevusan6879 2 года назад
@@Gort-ft4ey where? lol what the point to write that he has given something but no links for it ....
@shirocode7140
@shirocode7140 2 года назад
@@avgamer8050 just host the bot bro👍it would be online for months
@DemX_HaX
@DemX_HaX 2 года назад
god bless. you went straight to the point instead of a 5 min long intro or whatever most people do. im hungry for these kinds of tutorials.
@Deejaynerate
@Deejaynerate Год назад
What a great and comprehensive tutorial! I wanted to ask about displaying the exact elapsed time of the currently playing song, since I wanted to display that in the info page as well. Regardless, this video tackled the essentials that I was mostly interested with, and I'm glad to say that this is very well done!
@fishis3375
@fishis3375 2 года назад
Make more of these! I love them and very handy and easy to follow
@CodeEnthusiast78912
@CodeEnthusiast78912 Год назад
Thank you i made it work after some tweaks, it needed couple lines to be updates because of new discord.js version.
@yuyuolozaga3023
@yuyuolozaga3023 Год назад
What did you update if you don't mind me asking?
@deadfromhell1235
@deadfromhell1235 Год назад
I wanna know as well pls
@CodeEnthusiast78912
@CodeEnthusiast78912 Год назад
look at the github page guys i made a pull request all lines you need to update are there
@deadfromhell1235
@deadfromhell1235 Год назад
@@CodeEnthusiast78912 ye I checked it, but is was a mistake on my part haha copy paste did the trick :D
@_ciraz_
@_ciraz_ 7 месяцев назад
I always get thrown "No results", no matter which music video i try under 5 minutes length. Can anyone help?
@MyDantheman12345
@MyDantheman12345 2 года назад
Great video, really helped get me started on my own bot. I would be super interested in a video going through some of the extensions and settings you use for VS Code.
@karackac
@karackac Год назад
thanks man ! its been exactly a year since this video was created, i just realized haha
@ThePokemonrocks5
@ThePokemonrocks5 2 года назад
Hi there niconico! I'm really finding your tutorials very easy to follow. It's been a breeze so far. Though I am curious about the learning curve that's needed to study this. When I went into the discord js documentation it's kind of cryptic and hard to understand. Do you have any tips for someone like me who wants to branch out of the tutorial and learn to navigate on my own?
@Niconiconii
@Niconiconii 2 года назад
Practice and just use it. Discord’s api is imo one of the best documentations out there, even though there’s a lot of stuff involved. I’m not sure exactly what ur talking about as part of the learning curve (learning how to code in js, or make discord bots). But the essential skills r knowing fundamentals of how to code and knowing how to read documentation and debug code. Definitely go off the branch and add ur own features and all. That’s the way to learn. Following tutorials the whole way through with no change will significantly decrease the amount that u learn. Be creative with it. Try to do something engaging with some discord community or come up with features that could be for a public bot. Having feedback from others is very helpful and encouraging!
@TheNonsenseGuy
@TheNonsenseGuy Год назад
Hi there! I have snatched your code and fixed up the issues caused by the Discord js changes. The bot now mostly works except for one thing: using the "play" command stops the current song and immediately starts the next one instead of adding it to the queue. It's as if a new queue is created each time. I checked the discord player documentation and it says ".createQueue()" should return the existing queue if there already is one, so I really don't know what the problem is... Do you have a hunch as to what it could be?
@AuntHazel
@AuntHazel Год назад
hey would you mind to share with me how to fix this code? i'll be much appreciated
@joneswr1
@joneswr1 Год назад
im getting a createQueue error too (says its not a function) can you share your code?
@mozarellachan5854
@mozarellachan5854 Год назад
@@joneswr1 same bruh
@jikomowminecraft9278
@jikomowminecraft9278 2 года назад
he can't find the discord api type module in the index.js can you help me ?
@eternalspirits1533
@eternalspirits1533 2 года назад
when i tried to do node index.js load in the terminal i got this error i even tried downloading your files from github and i got the same error i did added the .env file and added TOKEN=my token Please could u help me fix this Error: Cannot find module 'dotenv' Require stack: - C:\Users\muham\OneDrive\Desktop\chillbotmusic\index.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15) at Function.Module._load (node:internal/modules/cjs/loader:804:27) at Module.require (node:internal/modules/cjs/loader:1028:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. (C:\Users\muham\OneDrive\Desktop\chillbotmusic\index.js:2:16) at Module._compile (node:internal/modules/cjs/loader:1126:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10) at Module.load (node:internal/modules/cjs/loader:1004:32) at Function.Module._load (node:internal/modules/cjs/loader:839:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\\Users\\user\\OneDrive\\Desktop\\chillbotmusic\\index.js' ]
@L300-nn
@L300-nn Год назад
Whenever i install the name packages i get like 100 errors and a few warns and i cant really tell what kind some say i miss permission to edit stuff and so on
@stealtime
@stealtime Год назад
I downloaded ffmpeg-static, but the audio in my channel only comes out of one speaker/side. Any solution?
@pepinatrojkarova6068
@pepinatrojkarova6068 2 года назад
Note: This problem has been solved. Solution in replies. Hi. I'm having a small problem. When I use the "node index.js load" the console says "Deploying slash commands" but then it says "S[50001]: Missing Access". Thanks in advance for help. I'm sure i just made a mistake in code.
@D_O_Art
@D_O_Art 2 года назад
i have the same error did you find a waqy to fix it?
@pepinatrojkarova6068
@pepinatrojkarova6068 2 года назад
Sadly not yet. And the discord server wasn't of any help either.
@mcmatt186
@mcmatt186 2 года назад
@@pepinatrojkarova6068 I had the same issue, basically, you're gonna want to go to your discord developer portal, go to OAuth2, check the applications.commands box, then copy the url it generates, paste that url into the browser, then accept the permission on the server you want it on
@pepinatrojkarova6068
@pepinatrojkarova6068 2 года назад
@@mcmatt186 Thanks a lot. Worked!
@Mrakantor6
@Mrakantor6 Год назад
Followed the tutorial and managed to deploy it, everything's fine, bot shows online and command list updated to the server. However my bot does not respond to my slashcommands. I'm getting "The application did not respond". Any ideas?
@diamonndgaming
@diamonndgaming Год назад
Hey do you have any idea why when I'm skipping a song. It skips the current song + the first song of the queue ? I'm using the same code as you
@tomas_obadal
@tomas_obadal Год назад
Hello, seems like i have kind of a problem with embed, it says, that MessageEmbed is not a constuctor. Could you please help me? ^_^
@SebaSefu
@SebaSefu Год назад
Change it to EmbedBuilder
@manwithplan906
@manwithplan906 2 года назад
I did everything correctly & got the bot to log in, but I don't see the slash commands when I type "/" in my chatroom. Any reasons?
@Niconiconii
@Niconiconii 2 года назад
u need to run it with the load option
@prometheusdevs9572
@prometheusdevs9572 2 года назад
*node index.js load* Hope this helps!
@VibeM4N
@VibeM4N 2 года назад
I think u think like me I was abt to code a music bot and voila you are here :) ❤️
@Niconiconii
@Niconiconii 2 года назад
Glad you found it helpful
@Zephrame
@Zephrame 10 месяцев назад
At the beginning you used two npm commands and then at the end you used a node command, are those part of the ffmpeg package?
@Schorri90
@Schorri90 3 месяца назад
@discordjs/opus not working anymore, is this required or can i skip this?
@kubx3106
@kubx3106 2 года назад
I did every thing good, command loaded, but the bot on discord when I am typing /Play url and enter It says application no responding any solution?
@Niconiconii
@Niconiconii 2 года назад
Add console.logs to check if code that u think is supposed to run is running. Feel free to join the discord server for more help discord.niconiconii.xyz
@kingacrisius
@kingacrisius Год назад
Anyone watching this video and having issues with the queue just doing whatever the hell it wants, run this command in console: npm i discord-player@5.3.2 The recent versions of discord-player are super broken, this will install a version that works for the purposes of this video.
@SebaSefu
@SebaSefu Год назад
Thank you so much
@AnswerAyeEye
@AnswerAyeEye Год назад
Discord pushed an update to how they handle things server side that has made the code in this bot obsolete, it will always stop playing music after 1 minute.
@Nicklepops
@Nicklepops Год назад
I have the same issue
@037tangerino
@037tangerino Год назад
I have a question, does the bot take music from RU-vid? if the bot pulls music from youtube i would like to learn how to make the bot pull music from spotify. Sorry for my English I'm from Spain
@Robert-ko2pq
@Robert-ko2pq Год назад
is it possible to host this bot on a server? ive done a similar method but when i try and host it it wont work. i think its because i dont know how to install ffmpeg onto the server. do you know if its possible?
@ВакуленкоАлексей-у2л
Will there be updated video/code with new discordjs things?
@perfectlkm
@perfectlkm Год назад
Whenever i run node index.js load or just node index.js i get Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined
@Mariqnski
@Mariqnski 2 года назад
Hi, I keep getting an error saying 'You are not authorized to perform this action on this application' when I type node index.js load can I get some help
@TaxFraudBruh
@TaxFraudBruh Год назад
Wheres the code for actually playing the queue cause I didn't see it?
@Criticzek
@Criticzek Год назад
Hey, I did everything like you, and when I wanna turn my bot on, this happen: Cannot find module 'dotenv' Throw err; ^ Require stack: *probably 10 or so lines* Code: Module not found', requireStack: (my disk here) } Node.js v18.12.1 [nodemon] app crashed - waiting for file changes before starting
@Criticzek
@Criticzek Год назад
Any help?
@브테-z8y
@브테-z8y 2 года назад
I didn't know where to write the prefix. Please tell me which file and which line. It's easy to follow, but it's hard to understand because I'm not good at English. But I think the video itself is good to follow.
@asvarius8760
@asvarius8760 2 года назад
it's a slashcommand handler, sou you just put /(command)
@DoomeR18G
@DoomeR18G 5 месяцев назад
I'm need python for this?
@core0001
@core0001 2 года назад
Komutları kullanınca uygulama yanıt vermedi diyor sonra çalışıyor. O uygulama yanıt vermediyi nasıl kaldırabilirim?
@peretz1714
@peretz1714 Год назад
i have a erroer : Error: Cannot find module 'discord.js pls help
@hajp
@hajp 2 года назад
I can't decide to actually choose language for my bot, Python seems to be much easier, but it has a small amount of tutorials, tho it's very powerful as JS, but JS has much more tutorials. Which one do you guys prefer?
@rea9lizer
@rea9lizer 2 года назад
I think JS is not much harder than Python if you decided to follow the video tutorial rather than make it from scratch. I'd say, choose one tutorial that seems detailed enough and just start following that! You can easily try out to use the other one later because you will learn not only how to code but also how discord bots and their codes work. But as you pointed out, I think there would not be many beginner's guides, especially for d.py 2.0 or one of its successors, which supports the latest features. P.S. I think Python is not very easier than JS technically, it's just way 'less annoying'!
@Niconiconii
@Niconiconii 2 года назад
i strongly recommend JS. it's got more tutorials/bigger community as mentioned by neon favor. But additionally, the docs for d.js is 1000x better than the d.py docs. Once you familiarize urself with javascript, if u want really neat and clean code, convert to typescript, which is javascript with typing
@snxphy
@snxphy 2 года назад
@@Niconiconii aswell as discord.py no longer having continued support
@Niconiconii
@Niconiconii 2 года назад
@@snxphy woah what happened to that lol
@snxphy
@snxphy 2 года назад
@@Niconiconii i think something to do with discord themselves and the developer giving up, cant remember.
@shirocode7140
@shirocode7140 2 года назад
hey, i can't understand how to download the ffmpeg, can you explain?
@tonygamer3178
@tonygamer3178 2 года назад
do npm i ffmpeg-static
@shirocode7140
@shirocode7140 2 года назад
when i tried it with the prefix command, it does send the confirmation message but did not play the song. I am sure that there are no errors with the command, i coded correctly, it searches correctly, i also added error checks, but not playing the song :( what could be the problem? if you want, i can post the code on pastebin and edit this msg adding the url of that.
@sr.dudu1233
@sr.dudu1233 2 года назад
same problem
@ricardojuarez5978
@ricardojuarez5978 2 года назад
Hi there, thx for your tutorial, it was quite easy to follow but I have an interesting situation. When I activate the bot there are no slash commands on the bot. I already executed the "node index.js load" and the bot was invited with the options "bot" & "application.commands" checked. I must wait a certain time or I missed a step? Anyways, great tutorial and thx
@vgarcia55
@vgarcia55 2 года назад
After following the video and getting to the last step where I "node index.js load" i get this error. Any suggestions? node:internal/modules/cjs/loader:936 throw err; ^ Error: Cannot find module 'C:\Users\vgarc\Desktop\JS\index.js' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []
@Niconiconii
@Niconiconii 2 года назад
U made a typo somewhere probably. Need to see the code. I recommend joining the discord for hekp
@anikdey9706
@anikdey9706 2 года назад
@@Niconiconii I also get this error
@dr_bluegaming
@dr_bluegaming 9 месяцев назад
My bot automatically logs out after 60 seconds :(
@schoolassignment2614
@schoolassignment2614 2 года назад
Did node index.js load into the terminal and nothing is happening
@Mysteec
@Mysteec 2 года назад
SyntaxError: Identifier 'Discord' has already been declared comes up with this what to do?
@ashacreed5203
@ashacreed5203 2 года назад
Hi there I loved the video but I encountered a hiccup, my terminal when trying to make a demo is saying "Cannot find module '@discord-api-types/v9'". Can anyone help me to fix it?
@Niconiconii
@Niconiconii 2 года назад
Remove the @
@lonediamond1995
@lonediamond1995 Год назад
hi hopefully you see this comment I'm new to coding In the index.js file when setting up the const why do some have {} example const {REST}
@mrmaniac9905
@mrmaniac9905 Год назад
No need to have seperate subcommands, just treat it like a chrome search, if http is present - it's a link. If not, its a query; you can use the actual url to determine if it's a playlist or not
@karma2535
@karma2535 2 года назад
Hey mate first of all i want to thank you for the easy and good tutorial, first one i actually found good and new. The bot works awsome but i wanted to ask you how do i change the bot initiation from "/" to another key and how do i make the bot like just type "/play speed" instead of having of "/play search searchitem speed"
@Niconiconii
@Niconiconii 2 года назад
You can remove the extra options. Try to copy the format from some other slash commands that don’t have the sub options for reference. I also recommend checking out the documentation in the discord-js guide!
@willtheed
@willtheed 2 года назад
Awesome video so easy to follow
@Niconiconii
@Niconiconii 2 года назад
Thank you
@Ticktok_of_Oz
@Ticktok_of_Oz Год назад
why is it that none of this matches the actual discord.js documentation?
@mralvisss69
@mralvisss69 2 года назад
I get this error, Error: Cannot find module '@discord-api-types/v9'. Why do i get this? Someone pls help :D
@brett5806
@brett5806 2 года назад
Remove the @ symbol at the beginning of that statement, worked for me!
@asvarius8760
@asvarius8760 2 года назад
hello sorry for bothering, I'm always getting this error: "client.slashcommands.set(slashcmd.data.name, slashcmd) ^ TypeError: Cannot read properties of undefined (reading 'name')" I don't know how to fix it, could you help me?
@_Vap
@_Vap 2 года назад
if you have an empty .js file in your commands folder, name comes out as undefined cause theres no name in that certain .js file
@avalanche8259
@avalanche8259 2 года назад
Hey nico the bot isnt working anymore did something change from the youtube api or something?
@Niconiconii
@Niconiconii 2 года назад
The bot is still working for me :shrug: I have four of them running in a server of mine 24/7. double check your code
@masterthodyu
@masterthodyu 2 года назад
Is there a way to prevent someone from entering a float when trying to skip pages or look at a queue page? Whenever someone entered a float in the field, it would crash my bot.
@Niconiconii
@Niconiconii 2 года назад
Use Math.round?
@Firewall141
@Firewall141 9 месяцев назад
is this thing working still on node 20.10?
@xberto_5098
@xberto_5098 2 года назад
My bot says: Successfully Loaded,. But it doesn't go online. Any fixes? There is no error shown in the terminal it's just not online
@axelcod2112
@axelcod2112 2 года назад
ten en cuenta que despues de colocar node index.js load debes de escribir de nuevo pero sin el load: node index.js concluson: debes poner el comando dos veces, uno con y sin el load
@HarryV123
@HarryV123 2 года назад
Hey I see my bot using the slash commands but it doesn't join the voice channel. does it have something to do with using V14 instead of V13? I've had to change some things so far because of that
@michaelwalters4749
@michaelwalters4749 2 года назад
Yeah mine wont join the channel and when using a command is simply said the application did not respond
@anikdey9706
@anikdey9706 2 года назад
Im hosting on heroku, but the bot is showing deafened
@Olaffstar
@Olaffstar 10 месяцев назад
can onyone help pls, why does it say this. (node:2740) [NoExtractors] Warning: Skipping extractors execution since zero extractors were registered
@ozguray00
@ozguray00 9 месяцев назад
did u fix that bro?
@sprintsutilities7669
@sprintsutilities7669 2 года назад
Hey, my bot is about to be verified and I cannot use a yotuube wrapper. Is this spotify or soundcloud api?
@Niconiconii
@Niconiconii 2 года назад
It has all three I believe.
@avalanche8259
@avalanche8259 2 года назад
Thank you for the well-explained tutorial.
@Fact_Fleets
@Fact_Fleets Год назад
what do i need to change to change the prefix into a "!"
@S0ak1128
@S0ak1128 Год назад
what about to play 24/7?
@klimbirukov1400
@klimbirukov1400 2 года назад
Hi, thanks for the cool video, but there is a question. When I enter "node index.js load" I get an error *index.js:36 client.slashcommands.set(slashcmd.data.name, slashcmd) TypeError: Cannot read properties of undefined (reading 'name') * The code is exactly the same as in the video
@asvarius8760
@asvarius8760 2 года назад
same
@_Vap
@_Vap 2 года назад
if you have an empty .js file in your commands folder, name comes out as undefined cause theres no name in that certain .js file
@superpodre
@superpodre 2 года назад
another question, the /play playlist bot is not playing the youtube playlist mix, is there any way to make it play?
@Niconiconii
@Niconiconii 2 года назад
I think youtube playlist mixes are a bit weird. For some reason it just doesn't work with the playlist things. I'm not sure why. I previously made a music bot that was supposed to be able to use playlists as well and I searched in a completely different method but couldn't get them to work with playlist mixes
@frainfx3353
@frainfx3353 2 года назад
If i type this in only errors pop up. There are many npm error texts in the terminal than. Can someone help me?
@Niconiconii
@Niconiconii 2 года назад
Join the discord server. Ur probably using an outdated version of node
@Adi-ee1ns
@Adi-ee1ns 2 года назад
Nico, I get this error everytime i try to turn the bot on client.slashcommands.set(slashcmd.data.name, slashcmd) ^ TypeError: Cannot read properties of undefined (reading 'name')
@rey-act5652
@rey-act5652 2 года назад
the same here
@echoopixel
@echoopixel 2 года назад
same
@Niconiconii
@Niconiconii 2 года назад
How did u define the commands in the actual files? And are you looking at the right directory? Maybe try console.log(slashcmd) before this line to see what the error is
@potatopineapple1237
@potatopineapple1237 2 года назад
@@Niconiconii error comes from "(index.js:37:44)
@Niconiconii
@Niconiconii 2 года назад
@@potatopineapple1237 that's supposed to be the line number of ur code...i dont see ur code so that's as good as telling me the error is on ur computer lmao
@marag598
@marag598 2 года назад
i followed this tutorial pretty well and the only problem i encountered was with the bot in discord, all the code was perfect, nothing wrong, but in discord, every time i would run a command it would say "the application did not respond" can you please help me
@marag598
@marag598 2 года назад
@@notanerdstudent how do i fix it?
@marag598
@marag598 2 года назад
@@notanerdstudent i got it to work but now it just says (*bot name) is thinking and nothing else
@Niconiconii
@Niconiconii 2 года назад
Feel free to join the discord server for more help discord.niconiconii.xyz
@fric_c103
@fric_c103 2 года назад
@@marag598 Hi, how did you get it work? I have the same issue...
@rafuu445
@rafuu445 2 года назад
I'm getting a error “Module not found ”
@Yorrickimi_yiyin
@Yorrickimi_yiyin Год назад
me too
@hitchhikertp2282
@hitchhikertp2282 Год назад
Thanks for the video! I'm having a few issues though, when I try to play a song from an url, it just returns "No results" to me. when I use the search function, it finds it but I can't hear the bot
@ffonceca
@ffonceca Год назад
Maybe you are missing the audio library
@sairentoakuma7514
@sairentoakuma7514 2 года назад
Unfortunately I can't install @discordjs/opus :(
@elmowococ2731
@elmowococ2731 Год назад
Hello I have a question I did what your tutorial said and I get this error: RangeError [BitFieldInvalid]: Invalid bitfield flag or number: GUILDS. at IntentsBitField.resolve (C:\Users\oscar ode_modules\discord.js\src\util\BitField.js:168:11) at C:\Users\oscar ode_modules\discord.js\src\util\BitField.js:163:54 at Array.map () at IntentsBitField.resolve (C:\Users\oscar ode_modules\discord.js\src\util\BitField.js:163:40) at new BitField (C:\Users\oscar ode_modules\discord.js\src\util\BitField.js:33:38) at new IntentsBitField (C:\Users\oscar ode_modules\discord.js\src\util\IntentsBitField.js:9:1) at Client._validateOptions (C:\Users\oscar ode_modules\discord.js\src\client\Client.js:482:25) at new Client (C:\Users\oscar ode_modules\discord.js\src\client\Client.js:78:10) at Object. (C:\Users\oscar\index.js:16:16) at Module._compile (node:internal/modules/cjs/loader:1159:14) { code: 'BitFieldInvalid' }
@ghc0802
@ghc0802 Год назад
change this: const { GatewayIntentBits } = require('discord.js') ...GUILDS (X) = >GatewayIntentBits.Guilds try again.
@Xaydz
@Xaydz 2 года назад
how do I fix it when I get the error message "BitFieldInvalid"?
@TheXtz11
@TheXtz11 2 года назад
i post a fix ... look down
@xaxaxoxo809
@xaxaxoxo809 2 года назад
heyy i cant use the slash command you know why ?
@jail8011
@jail8011 2 года назад
I can start the bot but the slash commands say your not authorized to perform this action
@Niconiconii
@Niconiconii 2 года назад
You need to invite the bot with slash command permissions checked in the oauth
@justmesdesu
@justmesdesu Год назад
thanks for the tutorial, somehow my bot is joining the channel but there is no audio playing :x I think i have the dependencies installed too...
@hello-ps1qm
@hello-ps1qm 2 года назад
can you help me with this error? throw new RangeError('BITFIELD_INVALID', bit); ^ RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: GUILD.
@Argo4
@Argo4 2 года назад
That means you haven't set up your intents correctly
@hello-ps1qm
@hello-ps1qm 2 года назад
try this const client = new Discord.Client({ Intents: [ "GUILDS", "GUILD_VOICE_STATES" ] })
@user-bm5dr8sw2s
@user-bm5dr8sw2s 2 года назад
@@hello-ps1qm hi i'm having the same error and tried this but still no change.... did you manage to fix it?
@TheXtz11
@TheXtz11 2 года назад
@@user-bm5dr8sw2s Fix it like this .. add this line in second position: const { Client, GatewayIntentBits } = require('discord.js') and add remplace the const client by this: const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, ] }) have fun
@gasbriel
@gasbriel 2 года назад
How would you play spotify songs? Do you have to use any spotify api?
@Niconiconii
@Niconiconii 2 года назад
it's done through the discord-player package. I'm not sure exactly how it actually works, but it probably uses an alternative method that isn't using the normal spotify api since that requires an api key which is not necessary for discord-player
@lonediamond1995
@lonediamond1995 Год назад
hi again can you share how you came about building this? you seem to just know how a lot of this works how did you figure it all?
@Niconiconii
@Niconiconii Год назад
figured it out at some point. u just gotta keep learning and keep building :)
@imvine
@imvine 2 года назад
Why would you have an /play info command if you can easily fit that also in the queue **Currently Playing**: [Song] _time-bar_ **Queue**: 1... 2... 3...
@Niconiconii
@Niconiconii 2 года назад
U can merge the two if u want. This is just the style I like lol.
@imvine
@imvine 2 года назад
@@Niconiconii I did. Also thanks for the awesome video! Helped me alot understanding how to do a music bot. I did it a bit different since i already had a own event handler and command handler. But i got stuck with how to actually play the songs and so on. I also merged all the play commands by filtering the string just to make it a bit cleaner.
@blade_xd6905
@blade_xd6905 2 года назад
awesome video and great community, how do i keep this bot online, i have used replit and a server hosting site in the past but idk how to do it with a local Bot. i am unsure as to how this works.
@chris08091
@chris08091 2 года назад
any way to make the bot play a file uploaded to discord? ex: upload a mp3 file to discord and make the bot play it
@Niconiconii
@Niconiconii 2 года назад
yes it is possible. If you read the discord-player docs you should find more information about this discord-player.js.org/docs/main/master/class/Track My guess would you would have to setup something that "streams" the music data constantly to the discord player which would then be able to play it in VC. It does come with some difficulty and I personally do not actually know the specifics of how it would be implemented. You'd have to do some research and poking around on your own.
@therealzach.b
@therealzach.b Год назад
Doubt if anybody is going to be reading this, but I'm getting a huge ass error when trying to do npm i @discordjs/opus, any ideas?
@baldursthones6542
@baldursthones6542 Год назад
Same problem as well, also looking for solutions.
@Fheara_Nyakki
@Fheara_Nyakki 2 года назад
Is there an updated guide of this? Hate when they change version of language and everything goes shit itself grrr, they changed a lot starting from this GatewayIntentBits and such ... which I managed with low knowledge of node js (always "played"with javascript in rpg maker mv...) to find GatewayIntentBits.Guilds and GatewayIntentBits.GuildVoiceStates but Im getting a error with the collection().
@TheXtz11
@TheXtz11 2 года назад
look down
@heo_yui
@heo_yui Год назад
hi me again, the bot stopped playing spotify out of the blue...
@JC-hk4vm
@JC-hk4vm Год назад
Really liked your video. Can you please share the VS code extension which you are using to smooth cursor (|) movement? Or is it just your OS? It's buttery smooth and got a cool animation while scrolling
@Niconiconii
@Niconiconii Год назад
made a tutorial about it on my channel. you should find it in the videos tab of my channel
@JC-hk4vm
@JC-hk4vm Год назад
@@Niconiconii sure thanks!!
@Pannavaro
@Pannavaro Год назад
Thank you so much bro, anyway can you do an extra video on how to make loop command?
@christopherbakkes5695
@christopherbakkes5695 2 года назад
Hi this was a great video super easy to understand for someone who has never worked with code before in his life. Was wondering if it was possible to add a prefix to this bot? if so how would you go about doing it ? even if you could point me in the right direction it would be helpful. thank you again.
@Niconiconii
@Niconiconii 2 года назад
Slash commands don’t have prefixes. What I would recommend is naming the slash commands individually so they are prefixed with something. For example, instead of /play make it /cplay and instead of /queue make it /cqueue
@christopherbakkes5695
@christopherbakkes5695 2 года назад
@@Niconiconii thank you i will try this
@D_O_Art
@D_O_Art 2 года назад
I keep getting the same error and i dont know how to fix it please help, errno: -4068 syscall: 'read', code: 'EISDIR' if someone knows what this means please help me
@D_O_Art
@D_O_Art 2 года назад
Error: EISDIR: illegal operation on a directory, read
@Cytxry007
@Cytxry007 2 года назад
hey for the queue, can u say the command for saving the queue?
@VibeM4N
@VibeM4N 2 года назад
Btw Nico Can I add this code to the bot already coded, followed by ur tutorials. I really want to add this to the main bot
@Niconiconii
@Niconiconii 2 года назад
I coded it very differently from the previous tutorials, so it will be a bit difficult to add to the other bot. Music bots tend to be a bit heavier on usage so I recommend keeping them actually separate from your main bot. If you want to use the same bot account you could just use the same token and it will work flawlessly!
@daitosio922
@daitosio922 2 года назад
Error: Cannot find module '@discord-api-types/v9' Require stack: - C:\Users\User\Desktop\discordmusic\index.js Pleas help what do i do?
@mralvisss69
@mralvisss69 2 года назад
I get the same error! Have you figured it out???
@Niconiconii
@Niconiconii 2 года назад
Remove the @
@aslaontop
@aslaontop 11 месяцев назад
how do i make that he can find spotify songs?
@kubx3106
@kubx3106 2 года назад
Not working, when /play searchterm (any song), joins the VC channel, sends the embed with song etc, but no sound and a lot things in console, among others: Cannot play something that has already ended.
@_rs2
@_rs2 2 года назад
It's an ytdl fault.
@uglyandsadboy
@uglyandsadboy 2 года назад
​@@_rs2 how can I fix this?
@Niconiconii
@Niconiconii 2 года назад
It’s outdated. I will do a new video soon
@bozo4923
@bozo4923 2 года назад
it says this to me Error: Cannot find module someone help?
@Niconiconii
@Niconiconii 2 года назад
Npm i
@ekbah
@ekbah 2 года назад
Hi. I really liked your way of explaining, but I did some mistakes that I've could fix by mysel or at least most of them, I have this error that says "TypeError: Cannot read properties of undefined (reading 'createQueue') ...\slash\play.js:33:47)" and I'm stuck with that, I don't know what to do. Help please :c
@Niconiconii
@Niconiconii 2 года назад
Need more context to the code to help I solve this. I recommend joining the discord suooort server
@ekbah
@ekbah 2 года назад
@@Niconiconii Alright then, and thank you.
@utkayfirat6293
@utkayfirat6293 2 года назад
how did u fix ?
@retiredff-champ
@retiredff-champ 2 года назад
Are you using v13 or which version pls reply.
@goodboyneon
@goodboyneon 2 года назад
v13.6
@retiredff-champ
@retiredff-champ 2 года назад
@@goodboyneon ohh thanks is it a new version which came in November?
@Niconiconii
@Niconiconii 2 года назад
yes it is. this is the current stable version for 2022
@retiredff-champ
@retiredff-champ 2 года назад
@@Niconiconii thanks !!! Niconiconii
@jonwho4231
@jonwho4231 Год назад
how would you add autoplay?
@komaru_7120
@komaru_7120 Год назад
I copied and pasted the index.js from your github (with changing the IDs) but it gives me an error about a "bitfieldinvalid" related to GUILDS.
@notwazural
@notwazural Год назад
"Guilds", "GuildMembers", "GuildMessages", "MessageContent", "GuildVoiceStates" try to replace it with this and it should work
@komaru_7120
@komaru_7120 Год назад
@@notwazural thanks I will!
@CeistDeuce
@CeistDeuce Год назад
Were you able to solve this at all? I'm having the same problem.
@komaru_7120
@komaru_7120 Год назад
@@CeistDeuce Look at the other reply, try that
@CeistDeuce
@CeistDeuce Год назад
@@komaru_7120 It loaded! It's just not online, and I don't know what to do with Node.js or FFmpeg.
@sr.dudu1233
@sr.dudu1233 2 года назад
mine doesn't play songs :(
@_rs2
@_rs2 2 года назад
If you migrated from discordjs v13 to v14 correctly then it's ytdl-core (it's used by discord-player) issue
@sr.dudu1233
@sr.dudu1233 2 года назад
@@_rs2 hey i'm using v14 i didn't used v13 idk why i can't play musics, i used console.log(queue) and i saw this: connection: StreamDispatcher { _events: [Object: null prototype] { error: [Function (anonymous)], debug: [Function (anonymous)], start: [Function (anonymous)], finish: [AsyncFunction (anonymous)] },
Далее
Просто топовый удлинитель!🔌
0:59