Register and Run Slash Commands (Discord.js v14)

Sdílet
Vložit
  • čas přidán 12. 12. 2022
  • Register and Run Slash Commands (Discord.js v14)
    🌐 Important links:
    Discord.js series playlist: • Discord.js v14 Tutorial
    Discord.js official website: discord.js.org
    Discord Commands Structure: discord.com/developers/docs/i... (Options & choices will be covered in the next video)
    Patreon: / underctrl
    Buy me a coffee (one-time donation): buymeacoffee.com/underctrl
    🎵 Music Credits:
    Track Name: "And So It Begins"
    Music By: Artificial Music @ / artificial-music
    Original upload HERE - / and-so-it-begins
    Official "Artificial Music" CZcams Channel HERE - / smarttoaster
    License for commercial use: Creative Commons Attribution 3.0 Unported "Share Alike" (CC BY-SA 3.0) License.
    Full License HERE - creativecommons.org/licenses/...
    Music promoted by NCM / @chillcopyrightfreemusic

Komentáře • 207

  • @UnderCtrl
    @UnderCtrl  Před rokem +12

    Source code: github.com/notunderctrl/discordjs-v14-series
    Discord server: discord.gg/T4faJeH84A

    • @Leafstuff
      @Leafstuff Před 9 měsíci

      hey i need help. at 5:49, when i try and run the node src/register-commands.js it comes up with
      registering slash commands...
      There was an error: DiscordAPIError[0]: 405: Method Not Allowed
      i followed you exactly but it isnt working and i cant find what the issue is.

    • @sharko_000
      @sharko_000 Před 9 měsíci

      @@Leafstuff replace the applicationGuildCommand to applicationGuildCommands (yes you only need to put "s")

  • @spl1c3
    @spl1c3 Před 6 měsíci +32

    Hey Under Ctrl. The odds of you seeing this are pretty low, but I want to say these videos have been helping immensely. Don’t ever stop what you do, man.

  • @ralphwiggum1203
    @ralphwiggum1203 Před rokem +6

    I love that you show how we can figure things out for ourselves like using console logs and documentations to find parameters

  • @satrajit
    @satrajit Před 11 měsíci +10

    By far the most useful video I could find about slash commands, extra props for actually writing the code live and not just dumping a bunch of pre-written code. Thank you for the very clear video :)

  • @Ender_Cafe_MDZ
    @Ender_Cafe_MDZ Před rokem +1

    I'm a viewer from Thailand. Your video clips teach, understand, easy to practice. Keep making good video clips. 😀

  • @vars8831
    @vars8831 Před rokem +9

    Very underappreciated tutorial. Good job man and your voice is perfect for this kind of videos.

  • @Arshlow
    @Arshlow Před rokem +3

    Thank you so much for your videos, I'm learning both English and Discordjs

  • @kortex_f-c_1817
    @kortex_f-c_1817 Před rokem +2

    Thank you for creating this video! I was looking for the way to add slash Commands, but other guides didn't help. After watching this video all works successfully.

  • @MasculineFortitudeX
    @MasculineFortitudeX Před rokem +1

    just got into nodejs heavily recently, thanks for showing how to set up nodemon -g it saves so much development time i believe instead of having to go back after every change to manually rerun code🤘

  • @git-sujon
    @git-sujon Před rokem +5

    Hello there! I am thoroughly enjoying the content that you produce. Your videos are of high quality and I have just subscribed to your channel. I kindly request that you consider making some videos on how to customize an OpenAI bot. Thank you!

  • @oscarthroedsson1410
    @oscarthroedsson1410 Před 8 měsíci

    You videos is so much better then discords tutorials.. Keep it comming

  • @BeelBellX
    @BeelBellX Před rokem

    Thank you very much, it helped me a lot.

  • @isseyyy69
    @isseyyy69 Před rokem

    you are explaining very good!

  • @MasculineFortitudeX
    @MasculineFortitudeX Před rokem

    this is awesome ! thanks

  • @Skilllssue
    @Skilllssue Před rokem

    Thank you! you recieved a subscriber

  • @abdielcuevas4281
    @abdielcuevas4281 Před 3 měsíci +4

    In case you get the following error "DiscordAPIError[50001]: Missing Access", in the GUID_ID put the server id

  • @grimgaunt.
    @grimgaunt. Před rokem

    Thank you~

  • @Pi_Maaster
    @Pi_Maaster Před rokem

    you are the best

  • @alexaligator
    @alexaligator Před 4 měsíci

    hey ! i really apriciate that you making these type of videos there are awesome tutorials! but i have a question can u explain why we need to add AppID token amd guildID to applicationguildcommand? at least i can undertand why for REST you need token that i don't get it why you need App ID and Guild ID , like we already creating bot and there no need of AppID . Also its a nice feature that you can test some command before lunch to global but why i how to change guildID that could works on every server?

  • @xanmal7042
    @xanmal7042 Před rokem +1

    I get no log messages. I don't get an error. the program just runs then turns off..

  • @DevNaN_
    @DevNaN_ Před 2 měsíci +2

    A little late for this, but what if I want it to be multi-server?

  • @the-name-is-mocha9570
    @the-name-is-mocha9570 Před 6 měsíci +1

    Amazing video, although i have one problem. The code is exactly the same however an error pops up when executing node src/register-commands.js, It tells me: There was an error: DiscordAPIError[50041]: Invalid API version. Any way how to fix this?

  • @darksantaeu
    @darksantaeu Před 10 měsíci +1

    i have an error when running node src/register-commands.js . it says discord API Error[1002] . Help?

  • @pHaace
    @pHaace Před 5 měsíci

    i dont get my bot in the slash commands space but cant see why its not working

  • @thiagolore7045
    @thiagolore7045 Před rokem

    how i make the slash commands appear in every server it is?

  • @user-tx2wb8dx5d
    @user-tx2wb8dx5d Před 10 měsíci

    what do i do when it says ReferenceError Route is not difined

  • @SFDark
    @SFDark Před 3 měsíci +1

    When i attempt to turn on the bot after writing the register-commands file, the bot straight up ignores it. No console.log events appear, no texts, no warnings. It just tells me that the bot is online. What did I do wrong?
    Edit: nevermind, i figured it out. I just had to run node src/register-commands.js first before turning on the bot. After doing that, the commands appear and work.

  • @DannyCheezits
    @DannyCheezits Před 7 měsíci

    any idea why each command gets registered twice indentically?

  • @automhate
    @automhate Před měsícem +1

    For anyone having the error: 0.name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid.
    make the name between the strings LOWERCASE! name: 'Hey' is NOT gonna work. Instead, try name: 'hey'

  • @user-qk4yv5yk2j
    @user-qk4yv5yk2j Před 7 měsíci

    You can help me? I have a error.
    ReferenceError: procces is not defined

  • @HuyMusicYTC
    @HuyMusicYTC Před 7 měsíci

    There was an error: DiscordAPIError[50035]: Invalid Form Body
    0.name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid. I have that error pls help me

  • @mollywater8715
    @mollywater8715 Před 6 měsíci

    these videos are very helpful but its so frustrating that in only a year everything updates to where it keeps throwing errors

  • @thatoneweirdkidthatyoudisl6723

    can someone help me, it say Routes.applicationGuildCommands not a function

  • @Inactivebiiiiiiiiit
    @Inactivebiiiiiiiiit Před rokem +2

    Great Video! But I have a question. I tried adding a new slash commands, but it doesn't seem like the code even recognizes that it's there. I've refreshed many times, but it still won't work. Is there a way you could help?

    • @UnderCtrl
      @UnderCtrl  Před rokem

      Hey. There’s a few reasons on why you might be getting that issue. My doubt is it’s probably your commands structure. Join my server discord.gg/T4faJeH84A and I’ll help you troubleshoot the problem.

  • @moman6456
    @moman6456 Před rokem

    hey bro ! fantastic vid, it really elps me out as im trying to learn coding, but i have a question, when i write the
    description: '....' it shows a problem and i cant figure it out, could u please help me?

    • @ashgaming3965
      @ashgaming3965 Před 9 měsíci

      the ... means there is more text than it can show on the description section of the avatar. try removing the newlines.

  • @fingore7530
    @fingore7530 Před rokem +4

    Hello, I was wondering if there was a way to have the GUILD_ID be set so that the bot can be accessible on any other server besides the test one you made, and I wasn't sure if this would be in a future video, so I am asking here now. I can be really bad at explaining things at times, so I hope you understand what I meant. Haha 😅

    • @fingore7530
      @fingore7530 Před rokem +1

      @@skid-rv8tz No sadly

    • @HarshalGaikwadcheekunikku
      @HarshalGaikwadcheekunikku Před 11 měsíci +1

      It's pretty simple, in register-commands.js replace
      await rest.put(
      Routes.applicationGuildCommands(clientId, guildId),
      { body: commands },
      );
      and instead put
      await rest.put(
      Routes.applicationCommands(clientId),
      { body: commands },
      );

  • @Marlon-ly4ui
    @Marlon-ly4ui Před 17 dny

    Hello Under Ctrl, i habe an strange issue. I build a discord app and i gave im the right rights as yours in the video. Then i build the bot and run him as a docker container. Now the strange starts. If i run him on my local maschine in docker compose the / commands working fine, but if i run him on my raspi the app crashes and say "discordjs can't regonize the command" . Its the same for a simple / gives text command and a / makes a database and fetch data command. Do you have some guesses why? I work with await interaction.deferReply({ ephemeral: true }); and interaction.editReply({
    content: "some content",
    }); and with interaction.reply({
    content: 'some content',
    ephemeral: true,
    }); nothing work on raspi. And Yes the commands are registert

  • @roto2134
    @roto2134 Před 7 měsíci +1

    how to remove a registered slash command ?

  • @TristanReeves1897
    @TristanReeves1897 Před 5 měsíci

    My commands won't show up, someone help me out pls?

  • @highstar_
    @highstar_ Před 11 měsíci +8

    i did everything correctly and rewatched this multiple times, but the commands dont work
    there are no errors, but when i use the slash command in the server, it says "the application did not respond"

    • @chickenmeatpizza
      @chickenmeatpizza Před 5 měsíci +1

      idrk the ans but there are some helpful ppl in the server of under ctrl so maybe join that ig

    • @EdgeFPS
      @EdgeFPS Před 2 měsíci

      same here..There is no error in the snippet..still in discord. the slash is not registering. DId you overcome the issue?

  • @aveyan23
    @aveyan23 Před 5 měsíci

    You forgot to add this thing 'npm i dotenv' , but overall 10/10

    • @UnderCtrl
      @UnderCtrl  Před 5 měsíci

      This video is part of a series, and dotenv was covered in the video before this (part 1)

  • @KaaNoFPS
    @KaaNoFPS Před 6 měsíci

    how do i get the design like you?

  • @mr.riceking9710
    @mr.riceking9710 Před rokem

    Noticing that your codeblock has far fewer whitespaces than mine.... I've been using TAB for indentation but is there a more formal way of doing this or should I continue with what I'm doing?

    • @UnderCtrl
      @UnderCtrl  Před rokem +1

      Yes, in your visual studio code settings you can change the “Tab size” to 2 which is what I use. Your seems to be 4

    • @mr.riceking9710
      @mr.riceking9710 Před rokem

      @@UnderCtrl Thank you! Keep up the amazing work man, been enjoying learning about discord.js.

  • @weightliftingcalisthenics3931
    @weightliftingcalisthenics3931 Před 10 měsíci +3

    @underctrl Its saying "there was an error: discordapierror [50035]: invalid form body name [application_command_invalid_name] command name is invalid... how to fix?

    • @kontorudaisuki6938
      @kontorudaisuki6938 Před 3 měsíci +2

      Same here, do you happen to fix it already by any chance?

  • @spirit8878
    @spirit8878 Před rokem

    I had a error with the slash command:
    DiscordAPIError[20012]: You are not authorized to preform this action on this application.

    • @L33bear
      @L33bear Před rokem

      your token is wrong

  • @weightliftingcalisthenics3931
    @weightliftingcalisthenics3931 Před 10 měsíci

    @Under Ctrl At 5:03 what did you click to put GUILD_ID down? Pleae help.

  • @zaixyu
    @zaixyu Před rokem

    i know this is kinda old but i cant seem to get my token to work, it says TypeError: (intermediate value).setToken(...) is not a function 😞

    • @immuchh
      @immuchh Před 11 měsíci

      const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);

  • @ShlokKapadia
    @ShlokKapadia Před rokem +2

    How can we delete the registered commands?
    I made some commands for test and now I cannot remove them from the discord command menu,
    Please help.

  • @rainsmcacc
    @rainsmcacc Před 11 měsíci

    Thanks for the last video was really helpful!
    and this is by far the best video yet on how to make discord bots!
    so right now im coming across this error when i type in "node src/register-commands.js"
    Registering Slash Commands...
    There was an Error: DiscordAPIError[50035]: Invalid Form Body
    name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
    What should I do to fix it? (I tried looking it up i wasn't able to find my answer so I thought maybe you would know.

    • @UnderCtrl
      @UnderCtrl  Před 11 měsíci

      One of your commands has an invalid name. Make sure it doesn’t have uppercase, spaces or any other special characters.

  • @Reedfender
    @Reedfender Před 9 měsíci +1

    I was getting error:
    Error at: DiscordAPIError[50035]: Invalid Form Body
    0.name[STRING_TYPE_REGEX]: String value did not match validation regex.
    Resolved by deleting {version: '10'} in line 11

    • @fishhairgel
      @fishhairgel Před 6 měsíci

      OMG I luv you! Was spending almost 2 hours rewriting, comparing code, all that!

  • @Zolac36
    @Zolac36 Před rokem

    thanks but I don't have handelcommands,handleevents folders :(

    • @UnderCtrl
      @UnderCtrl  Před rokem

      You don't need it for this video. We cover it later in the series.

  • @ik4k
    @ik4k Před měsícem

    hey so when i try to run the commands or check on it like node register-commands.js it does not work and the was same before when I have try to run the bot same does not work until i use client.login('');
    and I closed the .env (deleted) when I open a .env channel and use TOKEN = .... that doesn't work
    I hope you understand what I'm trying to explain

    • @ik4k
      @ik4k Před měsícem

      @UnderCtr

  • @OPMayo_VR
    @OPMayo_VR Před rokem +1

    Whenever i try to do this it says my console log for the error then "DiscordAPIError [50035]: invalid body name[STRING_TYPE_REGEX]: String value did not match validation regex.
    How do i fix this?
    figured it out, i just had to take away the ! point... took me 3 hours to figure that out.

    • @kontorudaisuki6938
      @kontorudaisuki6938 Před 3 měsíci

      May i know where you change it? cause I've been struggling with same problem and I don't know where to fix this

  • @jryer1
    @jryer1 Před rokem

    Can the index js send a slash command, even if there was no interaction initiated on the server? And will the Discord server run the slash command sent? I run windows, so my intent is to set up a daily schedule in the windows scheduler, that would run the js file at a given time everyday

    • @UnderCtrl
      @UnderCtrl  Před rokem

      If you want to send some message some time of the day, you can instead fetch the channel and send a regular message. You don't have to use slash command interactions for that. Interactions are only triggered when a user interacts in some way with your Discord bot.

    • @jryer1
      @jryer1 Před rokem

      @@UnderCtrl Can the js fetch the channel and send a slash command? I have a particular slash command on a private channel that performs a function. Right now I end up doing that manually on the channel each day, but I want the js to do it for me instead.

    • @HarshalGaikwadcheekunikku
      @HarshalGaikwadcheekunikku Před 11 měsíci +1

      ​@@jryer1 Yes, you can. If you want to find the channel by its id (get the id by right-clicking it in developer mode), then put this code (recommended if your bot is in multiple servers):
      channel = client.channels.cache.find(ch => ch.id === 'your-channel-id')
      If you instead want to find the channel by its name, enter this code (recommended if your bot is for one server):
      channel = client.channels.cache.find(ch => ch.name === 'your-channel-name')
      After this, you have to send the message using channel.send('This message was sent to its designated channel.')
      Here's how I would write your full code:
      // first, run npm install cron in your terminal
      // at the top of your file
      const cron = require('cron')
      // this next piece of code goes inside whatever client ready event you have, whether it is client.once(Events.ClientReady,...), client.once('ready',...), etc.)
      client.once('ready', (c) => {
      console.log(`${c.user.tag} is online`) // you may have something like this in your client ready event
      let scheduledMessage = new cron.CronJob('00 30 12 * * *', () => {
      // The format is seconds minutes hours, so 00 30 12 would send a message at 12:30 (please note this adjusts for your timezone)
      const channel = client.channels.cache.find(ch => ch.id === 'your-channel-id') // or channel = client.channels.cache.find(ch => ch.name === 'your-channel-name')
      // in the above line, if. you define your client as Discord.Client at the top of your code, replace "client" with Discord.Client
      channel.send('This message was sent at 12:30!');
      });

      scheduledMessage.start()
      });
      And that should be all! If you have any follow-up questions, please reply to this comment. Sorry for the long reply, but hope this helped!

    • @ashgaming3965
      @ashgaming3965 Před 9 měsíci +1

      @@jryer1 you could make a seperate file that does what the slas command does and then shedule the file to run eveyday using whatever you want

  • @aqfeet_clashroyale
    @aqfeet_clashroyale Před 11 měsíci

    @UnderCtrl it says for me that setToken(...) is not a function. I copied your code from Github so that means its the same as your, please help

    • @Pshock13y
      @Pshock13y Před 5 měsíci +1

      I had the same issue, make sure that when defining `const rest` that there is a semicolon(;) at the end of the declaration

  • @infini667
    @infini667 Před 2 měsíci

    Why not place the command registration in the main bot file, so that the commands are registered as soon as it starts?

    • @UnderCtrl
      @UnderCtrl  Před 2 měsíci

      You can do that as well, but I thought of having a separation between the two so I may explain things a little better. I cover command registration on startup later in the series using a command handler.

    • @infini667
      @infini667 Před 2 měsíci

      @@UnderCtrl Thanks! I was reading in the discord.js guide that it’s a good idea to put it in a separate file because Discord limits the number of times you can register commands daily. Now I’m trying to use SlashCommandBuilder() to create commands with options and permissions, but it’s giving me a body formatting error when registering the commands. I also read in the guide that you need to create a file for each command and do several other things... I think It's absurd for something that should be simple.
      I just watched your handler video... man, first of all, thank you for making these videos, and I think your method of doing things has a basis, but it adds too much complexity for something that is a simple registration and functionality of commands. I don't see the point in adding multiple files and folders. Bro, I have a bot made in Java (JDA) where the commands are registered with all options completed in literally 2 lines of code, and an event listener directs the actions to a command manager class. It's that simple. There must be a way to do this in a simpler way with JS.

  • @brycemiller9604
    @brycemiller9604 Před 4 měsíci +3

    For anyone who possible gets this error CODE: "DiscordAPIError[50035]: Invalid Form Body
    0.name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid"
    your command names have to be all lowercase. literally spent 45 minutes trying to figure this out. Hope it saves someone some time

  • @gta_ishan
    @gta_ishan Před měsícem

    Hello i tried the .env but idk it just throws error of invalid token

    • @KAE00015
      @KAE00015 Před 27 dny

      save all your files by going through every file and hitting ctrl + s

  • @XxprogamerezcerezxX
    @XxprogamerezcerezxX Před 11 měsíci

    it sends me an empty message box

  • @justecho5760
    @justecho5760 Před 4 měsíci

    I dunno why, but it didn't work for me :(

  • @misty5130
    @misty5130 Před 2 měsíci

    Hello! Thank you so much for these tutorials. Something I noticed is that every time I add commands to my bot, I have to kick and reinvite it for the new commands to show up. Is there a way to have them automatically appear without a kick/rejoin?

    • @UnderCtrl
      @UnderCtrl  Před 2 měsíci +1

      Hey. So that's most likely a Discord caching issue with the desktop app. Instead of kicking the bot and re-inviting it, I suggest just refreshing your Discord using Ctrl + R (Cmd + R on mac) and you'll get updated commands.

    • @misty5130
      @misty5130 Před 2 měsíci

      @@UnderCtrl Thank you, I'll give it a shot!

  • @aiwanano6507
    @aiwanano6507 Před 8 měsíci +12

    If your code for around 5:34 is not running (like it's not printing anything, just ignoring), make sure you add a (); at the end in order to invoke the function.
    Problem (console):
    Node.js v18.15.0
    PS C:\Users\W\EconomyBot> node src/register-commands.js
    PS C:\Users\W\EconomyBot>
    Example:
    (async () => {
    try {
    console.log("Registering slash commands...");
    await rest.put(
    Routes.applicationGuildCommands(
    process.env.CLIENT_ID,
    process.env.GUILD_ID
    ),
    { body: commands }
    );
    console.log("Slash commands registered.");
    } catch (error) {
    console.log(`Error: ${error}`);
    }
    })();
    The (); at the last line invokes the entire function and makes it run.

  • @MetaIsRG4L
    @MetaIsRG4L Před rokem +4

    @underctrl I get an error that says: There was an Error: DiscordAPIError[0]: 405: Method Not Allowed. Can someone help me?

  • @fitzy121fitzgerald5
    @fitzy121fitzgerald5 Před 8 měsíci

    hey i was working on this and when i hit the 5:56 minutes part i got discord is undefined cant find a solution to it?

  • @dapesaDVD
    @dapesaDVD Před 9 měsíci

    As the Discord.js documentation says: "it's not a very good idea to have a single file with a giant if/else if chain for commands. If you want to implement features into your bot and make your development process a lot less painful, you'll want to implement a command handler."
    This way works, but is not the best one.

    • @UnderCtrl
      @UnderCtrl  Před 9 měsíci +1

      Agreed! This is just an approach for beginners. In later videos I have covered multiple command handlers that handle registration.

  • @lzimport
    @lzimport Před rokem

    bro,you're a god.
    did you have any udemy course? or any course besides youtube? i would like to pay damm

    • @UnderCtrl
      @UnderCtrl  Před rokem +1

      Thank you so much for the positive comment! 😊 I don’t have any courses yet but I am planning to create one which covers the Discord.js library.

    • @lzimport
      @lzimport Před rokem

      @@UnderCtrl just have a quick question,how to you keep the bot online withouth need the pc?

    • @UnderCtrl
      @UnderCtrl  Před rokem

      You have to host it on a server. You’d usually rent a server for that

  • @Nixthefurry
    @Nixthefurry Před 5 měsíci

    hey @underctrl im having the problem of it having too many commands that i dont want

  • @kingananas2.0
    @kingananas2.0 Před rokem +1

    The env stuff does'nt work for me. It only says that the Token is invalid, i've resetted it and added it to the file, but it still doesn't work.

    • @UnderCtrl
      @UnderCtrl  Před rokem

      Make sure .env is in the root level, not inside the src folder.

    • @kingananas2.0
      @kingananas2.0 Před rokem

      @@UnderCtrl it is in the root level

    • @stryff
      @stryff Před rokem

      @@UnderCtrl lmao been stumped on this ty

  • @kxhna
    @kxhna Před 7 měsíci +2

    When I try to run the register-commands.js file it says "DiscordAPIError[0]: 405: Method Not Allowed"
    How do i fix this?

    • @pcgg-kb4eg
      @pcgg-kb4eg Před 7 měsíci +1

      Same here

    • @stijn_gamet
      @stijn_gamet Před 7 měsíci +1

      applicationGuildCommands not applicationGuildCommand

  • @midwesternlassalle
    @midwesternlassalle Před rokem

    Bruh, it keeps saying settoken is not a function. Y'know anyway to fix this? i've been scratching my head for the past 2 hours

  • @jacklondon2663
    @jacklondon2663 Před 6 měsíci

    hey, can other users use these commands as well? i mean does bot reply them too?

    • @wetn
      @wetn Před 5 měsíci +3

      Yes

  • @j0ppi
    @j0ppi Před rokem

    for me everything work, but when i try to make a second command, it's doesn't work :/ 9:24

    • @tariqplays5826
      @tariqplays5826 Před 23 dny

      same, the application doesn't respond and throws an unknown interaction error

  • @bezarwashere
    @bezarwashere Před 7 měsíci

    Im having a problem it says:
    There was an error: DiscordAPIError[0]: 405: Method Not Allowed

    • @stijn_gamet
      @stijn_gamet Před 7 měsíci

      applicationGuildCommands not applicationGuildCommand

  • @SreekalaS-cj9bs
    @SreekalaS-cj9bs Před rokem +1

    broo i prmblmm my slash code is registering but after that insted of registerd successfully There was an error: Error: Expected token to be set for this request, but none was present this is showing wt is prob

    • @trrzy8394
      @trrzy8394 Před 5 měsíci

      I have that same problem, havent figured it out yet

    • @ilovelampadaire
      @ilovelampadaire Před 2 měsíci

      You need to be in the folder before the src folder and then, do: node src/register-commands.js

  • @lukegilson2917
    @lukegilson2917 Před rokem

    it keeps saying invalid token provided when I know its the right token

  • @robhopper5729
    @robhopper5729 Před 11 měsíci

    when I run the command node src/register-commands.js it doesn't do anything. No errors, no / commands on my server. nothing. Just keeps running like nothing happened.

    • @UnderCtrl
      @UnderCtrl  Před 11 měsíci

      Try restarting the terminal and try again. If the issue still persists please join my Discord and share your issue there: discord.underctrl.io

    • @usernamesareuseless262
      @usernamesareuseless262 Před 8 měsíci

      Idk if you still have this problem. But you most likely forgot to add a (); at the end of the async function.

  • @perfect.999
    @perfect.999 Před 2 měsíci

    i wrote a slash command with ur tutorial, the command itself works properly however i can use this command once and my bot crashes and i have to restart my bot, any help? @UnderCtrl

  • @Gfragakhs
    @Gfragakhs Před 2 měsíci

    i tried everything but i couldnt get the src/register-command.js to respond i have the exactly same code as you and it doesnt respond. i need a bit help

    • @BANGPOWBANGPOWPOW
      @BANGPOWBANGPOWPOW Před měsícem

      Your .env file might not be where it should or something of the sorts, where `process.env.thingy` is used, try using the bare "strings!"

  • @spellq8367
    @spellq8367 Před rokem +2

    Nice video, but i have problem DiscordAPIError[50035]: Invalid Form Body
    name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid.
    Can you help me solve this?

    • @UnderCtrl
      @UnderCtrl  Před rokem +7

      One of the commands you’re registering has an invalid name. Make sure it doesn’t have any space, only letters and make sure it’s all in lowercase. If all your command names are fine then check your options inside your commands to follow the same pattern. Options can however use “-“ in their names.

    • @spellq8367
      @spellq8367 Před rokem +2

      @@UnderCtrl You are the only one who really helped me with writing the bot, thanks so much !

    • @Zaheed_And_Jordyn
      @Zaheed_And_Jordyn Před rokem

      ​@@UnderCtrlWhat do you mean by that?

  • @xxlilnovaxx
    @xxlilnovaxx Před rokem

    Why do i keep getting this?
    node:internal/modules/cjs/loader:1093
    throw err;
    ^
    Error: Cannot find module 'C:\Users\justd\Downloads\NovaBotBeta\src
    egister-commands.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1090:15)
    at Module._load (node:internal/modules/cjs/loader:934:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
    code: 'MODULE_NOT_FOUND',
    requireStack: []
    }
    Node.js v19.8.1

    • @RoganShorts2715
      @RoganShorts2715 Před rokem

      dont type nodemon just type node src/the name of your file. this worked for me

    • @xxlilnovaxx
      @xxlilnovaxx Před rokem

      @@RoganShorts2715 ok ill try it, thank you

  • @YourLocalPeanutButterEnjoyer

    every time i run .setToken, i get given an error, and not processed thru console.log. im using discord.js version 14.14.1

    • @BANGPOWBANGPOWPOW
      @BANGPOWBANGPOWPOW Před měsícem +1

      If the error is something like: "setToken is not a function" then add the semi colon to the end of it. (I know I'm late.)

    • @Apollo46150
      @Apollo46150 Před měsícem

      @@BANGPOWBANGPOWPOWThank you so much! I was stuck here for like 10 minutes.

  • @lukegilson2917
    @lukegilson2917 Před rokem

    also the .settoken isn't a function no more.

  • @eonharper1824
    @eonharper1824 Před rokem

    When i run this it says MODULE_NOT_FOUND
    Could i please have help
    thanks

    • @UnderCtrl
      @UnderCtrl  Před rokem +1

      Quite a few reasons why that could happen. Please join my Discord for help: discord.underctrl.io

    • @eonharper1824
      @eonharper1824 Před rokem

      @@UnderCtrl alright thank you

  • @Zolac36
    @Zolac36 Před rokem

    how to get the src file???

    • @UnderCtrl
      @UnderCtrl  Před rokem

      The src folder is what we created in the first video. It's not important if you already have an existing project. You can just create all your files and folders in your current directory. If you do choose a src folder make sure to change "main" in package.json to "src/index.js"

  • @splashyreacts
    @splashyreacts Před rokem

    how do i make the bot respond with the interaction author username?

    • @UnderCtrl
      @UnderCtrl  Před rokem +2

      interaction.reply(`Hey there ${interaction.member.username}!`)

    • @splashyreacts
      @splashyreacts Před rokem

      @@UnderCtrl thanks! How do I define the username? Its responding Hey there undefined

  • @tennlam4356
    @tennlam4356 Před 7 měsíci

    I get the following error: An error has occured: DiscordAPIError[50035]: Invalid Form Body application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
    Does anyone know how to fix this?

    • @robotmercenary8844
      @robotmercenary8844 Před 7 měsíci

      After Troubleshooting for a moment, My issue was the env file was not saved. Make sure you save the env file so that the functions are actually retrievable.

    • @darkzy6950
      @darkzy6950 Před měsícem

      @@robotmercenary8844DUDE I LOVE YOU

    • @darkzy6950
      @darkzy6950 Před měsícem

      @@robotmercenary8844saved me so much

  • @Zerokopas
    @Zerokopas Před rokem

    I have error method not allowed

  • @gooseman4776
    @gooseman4776 Před 5 měsíci +1

    How can i fix it?:
    There was an error: DiscordAPIError[0]: 405: Method Not Allowed

    • @LIL_13EN
      @LIL_13EN Před 5 měsíci +1

      applicationGuildCommands, I forget add the 's' at the tail , now is working

    • @zynphxz1694
      @zynphxz1694 Před 3 měsíci

      @@LIL_13EN you saved me bro

  • @beezy-3505
    @beezy-3505 Před 4 měsíci

    Hey in minute 5.56 i get an typeError .setToken isnot a function please help me solve it

    • @SlimeyHD
      @SlimeyHD Před 3 měsíci +1

      I got it too and adding a semicolon behind the line with the setToken function fixed it

  • @_MAGMI
    @_MAGMI Před rokem

    why do we need the guild id ?

    • @UnderCtrl
      @UnderCtrl  Před rokem +1

      To register commands to that specific server only. Global commands can take time to register

  • @ImAlxer
    @ImAlxer Před 3 měsíci

    undefined value in guild id and user id wtf

  • @sparrowTTV
    @sparrowTTV Před rokem +1

    For those of you getting "TypeError: (intermediate value).setToken(...) is not a function".......................put a SEMICOLON after "const rest = new REST({ version: '10' }).setToken(process.env.TOKEN)"

  • @bendeguzbenkovics903
    @bendeguzbenkovics903 Před 2 měsíci

    Hello! I got an error:
    DiscordAPIError[50035]: Invalid Form Body
    application_id[NUMBER_TYPE_COERCE]: Value "1184131001585250374, 1184132196659908618" is not snowflake.
    guild_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.

  • @Boxed-matt
    @Boxed-matt Před 3 měsíci +1

    Hey where do you find the guild Id ??

    • @LogoSystemCG
      @LogoSystemCG Před 2 měsíci

      this is your discord server ID

    • @theemeraldend4302
      @theemeraldend4302 Před měsícem

      I made this mistake too. You need to right click the discord server name. not left click. It looks like Two seperate menus but they look increadibly similar

  • @Himanshupatel-ij3zq
    @Himanshupatel-ij3zq Před 9 měsíci

    I am getting multiple instance for single input
    user input: Hi
    Bot Output: Hey
    Hey
    Hey

    • @UnderCtrl
      @UnderCtrl  Před 9 měsíci

      That is probably because you have multiple terminals open

    • @Himanshupatel-ij3zq
      @Himanshupatel-ij3zq Před 9 měsíci

      @@UnderCtrl thanks I got solution from your discord.

  • @Bluei2h
    @Bluei2h Před rokem

    Everything is going well, but i am experiencing a problem
    (async() => {
    ^
    TypeError: (intermediate value).setToken(...) is not a function
    at Object. (C:\Users\294ad\Captain's Utilities\src
    egister-commands.js:13:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

    • @williamdragon1023
      @williamdragon1023 Před rokem

      Use client.application.commands.set(commandsArray);

    • @hamm3rman199
      @hamm3rman199 Před rokem +2

      I experienced the similar problem, but I figured out how to fix it:
      const rest = new REST({ version : '10'}).setToken(process.env.TOKEN);
      You must have corrected it or something by now.

    • @mariesaoconnell7281
      @mariesaoconnell7281 Před rokem +1

      This happened to me, I missed the set of parentheses at the very end

    • @kanlin2501
      @kanlin2501 Před 10 měsíci

      spent 30 min on this error, the semi colon is required when defining rest.
      this works:
      const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
      this doesnt:
      const rest = new REST({ version: '10' }).setToken(process.env.TOKEN)

  • @twojmruczus
    @twojmruczus Před rokem

    um.. ;-; that's not exactly working

  • @hackerboomm.official
    @hackerboomm.official Před 11 měsíci

    I tried this code but there is an error like this:
    🔴 Error is: DiscordAPIError[50035]: Invalid Form Body
    Can someone help!

    • @hackerboomm.official
      @hackerboomm.official Před 11 měsíci

      I solved the problem anyways

    • @immuchh
      @immuchh Před 11 měsíci

      please help me with that as i have the same problem

  • @troll3917
    @troll3917 Před 6 měsíci

    Hey, great video! Although, I am facing a problem.
    P.S - RMP_ID is my Bot user ID.
    My code is running, however, I don't see the applications for the bot, this is my code:
    require('dotenv').config();
    const { REST, Routes } = require('discord.js')
    const cmds = [
    {
    name: 'Test',
    description: 'Replies with RMP online'
    }
    ];
    const rest = new REST({ version: '10'}).setToken(process.env.TOKEN);
    (async () =>{
    try{
    console.log('Registering slash commands...');
    await rest.put(
    Routes.applicationGuildCommands(process.env.RMP_ID, process.env.GUILD_ID)
    );
    console.log('Slash commands prompts registered.');
    }catch (error){
    console.log(`There was an error ${error}`);
    }
    })();
    Any help is appreciated, thanks!

  • @thespacemanfil4921
    @thespacemanfil4921 Před rokem

    4:32
    Replace your fire alarm batteries bro

    • @UnderCtrl
      @UnderCtrl  Před rokem +1

      LOL! Those were cars honking if I remember correctly. At that time I didn't bother doing a retake on them xD