Register and Run Slash Commands (Discord.js v14)

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024
  • 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/de... (Options & choices will be covered in the next video)
    Patreon: / underctrl
    Buy me a coffee (one-time donation): buymeacoffee.c...
    🎵 Music Credits:
    Track Name: "And So It Begins"
    Music By: Artificial Music @ / artificial-music
    Original upload HERE - / and-so-it-begins
    Official "Artificial Music" RUclips Channel HERE - / smarttoaster
    License for commercial use: Creative Commons Attribution 3.0 Unported "Share Alike" (CC BY-SA 3.0) License.
    Full License HERE - creativecommon...
    Music promoted by NCM / @chillcopyrightfreemusic

Комментарии • 218

  • @UnderCtrl
    @UnderCtrl  Год назад +14

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

    • @Leafstuff
      @Leafstuff 11 месяцев назад

      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 11 месяцев назад

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

    • @TheFirstDEv1L
      @TheFirstDEv1L 3 дня назад

      ​@@Leafstuff.

  • @spl1c3
    @spl1c3 7 месяцев назад +36

    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.

    • @UnderCtrl
      @UnderCtrl  7 месяцев назад +8

      Thanks! 🙏

  • @satrajit
    @satrajit Год назад +11

    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 :)

  • @ralphwiggum1203
    @ralphwiggum1203 Год назад +6

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

  • @vars8831
    @vars8831 Год назад +9

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

  • @aiwanano6507
    @aiwanano6507 9 месяцев назад +15

    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.

    • @zombiepigmandude7759
      @zombiepigmandude7759 9 месяцев назад +2

      thank you you beautiful man

    • @Shrey_Yash
      @Shrey_Yash 2 месяца назад +1

      Thank you so much internet stranger, may all the blessings be with you

    • @amysgamingadventures
      @amysgamingadventures 2 месяца назад

      Thank you! This helped!

    • @JalalOsamaa
      @JalalOsamaa 19 дней назад

      yeah it uses an immediately invoked function expression
      if u didnt want, u can identify it and then call it
      like this
      (remove brackets around async) async function registerSlashCommands() {..rest of code}
      then use registerSlashCommands()

    • @Pepperoni1005
      @Pepperoni1005 13 дней назад

      thanks for writing this comment, was stugling on this, but luckily loooked in the commend section

  • @kortex_f-c_1817
    @kortex_f-c_1817 Год назад +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.

  • @jokerface345
    @jokerface345 Год назад +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 Год назад +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!

  • @maltyhopperbrewing5513
    @maltyhopperbrewing5513 19 дней назад

    Amazing videos. Even after following the tutorial I’m still messing up, resulting in me researching and looking for my mistake which I think is a great way to learn although frustrating.

  • @Ender_Cafe_MDZ
    @Ender_Cafe_MDZ Год назад +1

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

  • @Arshlow
    @Arshlow Год назад +3

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

  • @abdielcuevas4281
    @abdielcuevas4281 5 месяцев назад +4

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

  • @highstar_
    @highstar_ Год назад +9

    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 7 месяцев назад +1

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

    • @EdgeFPS
      @EdgeFPS 4 месяца назад

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

  • @nerusnf
    @nerusnf 15 дней назад +1

    Thank you!

  • @oscarthroedsson1410
    @oscarthroedsson1410 9 месяцев назад

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

  • @DevNaN_
    @DevNaN_ 3 месяца назад +2

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

  • @brycemiller9604
    @brycemiller9604 6 месяцев назад +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

  • @isseyyy69
    @isseyyy69 Год назад

    you are explaining very good!

  • @weightliftingcalisthenics3931
    @weightliftingcalisthenics3931 Год назад +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?

    • @Apsihbg
      @Apsihbg 5 месяцев назад +2

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

  • @the-name-is-mocha9570
    @the-name-is-mocha9570 7 месяцев назад +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?

  • @smartbox943
    @smartbox943 11 дней назад

    gives me this error: DiscordAPIError[20012]: You are not authorized to perform this action on this application every time i try the node src/register-command.js command

  • @sparrowTTV
    @sparrowTTV Год назад +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)"

    • @hredd9299
      @hredd9299 10 месяцев назад +1

      I tried this but still keep getting an error

    • @Likeable_Emmec
      @Likeable_Emmec 2 месяца назад

      My saviour!

  • @aveyan23
    @aveyan23 7 месяцев назад

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

    • @UnderCtrl
      @UnderCtrl  7 месяцев назад +1

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

  • @kxhna
    @kxhna 9 месяцев назад +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 9 месяцев назад +1

      Same here

    • @stijn_gamet
      @stijn_gamet 9 месяцев назад +1

      applicationGuildCommands not applicationGuildCommand

  • @SFDark
    @SFDark 4 месяца назад +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.

  • @ShlokKapadia
    @ShlokKapadia Год назад +3

    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.

  • @xanmal7042
    @xanmal7042 Год назад +1

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

  • @jokerface345
    @jokerface345 Год назад

    this is awesome ! thanks

  • @BeelBellX
    @BeelBellX Год назад

    Thank you very much, it helped me a lot.

  • @MetaIsRG4L
    @MetaIsRG4L Год назад +4

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

    • @SKoRSA
      @SKoRSA Год назад +1

      To resolve this error, you can try using a different username that does not contain "discord".

    • @weightliftingcalisthenics3931
      @weightliftingcalisthenics3931 Год назад

      ​@@SKoRSAwhat do you mean by username, it's giving me this error now too?

    • @weightliftingcalisthenics3931
      @weightliftingcalisthenics3931 Год назад

      The require name?

    • @stijn_gamet
      @stijn_gamet 9 месяцев назад

      applicationGuildCommands not applicationGuildCommand

  • @dapesaDVD
    @dapesaDVD 10 месяцев назад

    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  10 месяцев назад +1

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

  • @skcarti
    @skcarti Год назад

    Thank you! you recieved a subscriber

  • @darksantaeu
    @darksantaeu Год назад +1

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

  • @alexaligator
    @alexaligator 5 месяцев назад

    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?

  • @Rezgc_
    @Rezgc_ 24 дня назад

    i keep getting There was and error: ReferenceError: Routes is not defined does anyone know how to fix? i trid to fix it but made it worse now its saying Expected token to be set for this request, but none was present

  • @infini667
    @infini667 3 месяца назад

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

    • @UnderCtrl
      @UnderCtrl  3 месяца назад

      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 3 месяца назад

      @@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.

  • @Reedfender
    @Reedfender 10 месяцев назад +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 7 месяцев назад

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

  • @Inactivebiiiiiiiiit
    @Inactivebiiiiiiiiit Год назад +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  Год назад

      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.

  • @Pi_Maaster
    @Pi_Maaster Год назад

    you are the best

  • @Marlon-ly4ui
    @Marlon-ly4ui 2 месяца назад

    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

  • @meowmeowmath
    @meowmeowmath Год назад +1

    Hey I'm getting: TypeError: (intermediate value).setToken(...) is not a function. What does this mean? It doesn't let me run any slash commands:(

    • @immuchh
      @immuchh Год назад

      replace the similar code with this
      const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);

    • @hredd9299
      @hredd9299 10 месяцев назад

      @@immuchh I tried this yet still keep getting the same error any tips?

    • @immuchh
      @immuchh 10 месяцев назад

      @@hredd9299 ^

    • @jacobymryoutube
      @jacobymryoutube 3 месяца назад

      Prob very late, but add a semicolon at the end of the line of code (with the .setToken part).

  • @grimgaunt.
    @grimgaunt. Год назад

    Thank you~

  • @thiagolore7045
    @thiagolore7045 Год назад +1

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

  • @fingore7530
    @fingore7530 Год назад +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 Год назад +1

      @@skid-rv8tz No sadly

    • @HarshalGaikwadcheekunikku
      @HarshalGaikwadcheekunikku Год назад +2

      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 },
      );

  • @OPMayo_VR
    @OPMayo_VR Год назад +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.

    • @Apsihbg
      @Apsihbg 5 месяцев назад

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

  • @roto2134
    @roto2134 9 месяцев назад +1

    how to remove a registered slash command ?

  • @gooseman4776
    @gooseman4776 7 месяцев назад +1

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

    • @LIL_13EN
      @LIL_13EN 7 месяцев назад +1

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

    • @zynphxz1694
      @zynphxz1694 5 месяцев назад

      @@LIL_13EN you saved me bro

  • @lzimport
    @lzimport Год назад

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

    • @UnderCtrl
      @UnderCtrl  Год назад +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 Год назад

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

    • @UnderCtrl
      @UnderCtrl  Год назад

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

  • @thatoneweirdkidthatyoudisl6723
    @thatoneweirdkidthatyoudisl6723 2 месяца назад

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

  • @pHaace
    @pHaace 7 месяцев назад

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

  • @mollywater8715
    @mollywater8715 8 месяцев назад

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

  • @mr.riceking9710
    @mr.riceking9710 Год назад

    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  Год назад +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 Год назад

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

  • @spellq8367
    @spellq8367 Год назад +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  Год назад +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 Год назад +2

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

    • @Zaheed_And_Jordyn
      @Zaheed_And_Jordyn Год назад

      ​@@UnderCtrlWhat do you mean by that?

  • @DannyCheezits
    @DannyCheezits 9 месяцев назад

    any idea why each command gets registered twice indentically?

  • @user-qk4yv5yk2j
    @user-qk4yv5yk2j 8 месяцев назад

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

  • @HuyMusicYTC
    @HuyMusicYTC 9 месяцев назад

    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

  • @kingananas2.0
    @kingananas2.0 Год назад +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  Год назад

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

    • @kingananas2.0
      @kingananas2.0 Год назад

      @@UnderCtrl it is in the root level

    • @stryff
      @stryff Год назад

      @@UnderCtrl lmao been stumped on this ty

  • @moman6456
    @moman6456 Год назад

    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 10 месяцев назад

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

  • @TdogThePog2015
    @TdogThePog2015 6 месяцев назад

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

  • @misty5130
    @misty5130 4 месяца назад

    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  3 месяца назад +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 3 месяца назад

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

  • @jryer1
    @jryer1 Год назад

    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  Год назад

      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 Год назад

      @@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 Год назад +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 10 месяцев назад +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

  • @justecho5760
    @justecho5760 6 месяцев назад

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

  • @SreekalaS-cj9bs
    @SreekalaS-cj9bs Год назад +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 7 месяцев назад

      I have that same problem, havent figured it out yet

    • @ilovelampadaire
      @ilovelampadaire 3 месяца назад

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

  • @ik4k
    @ik4k 3 месяца назад

    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 3 месяца назад

      @UnderCtr

    • @Day_Tac
      @Day_Tac 29 дней назад

      @Under Cntrl

  • @KaaNoFPS
    @KaaNoFPS 7 месяцев назад

    how do i get the design like you?

  • @weightliftingcalisthenics3931
    @weightliftingcalisthenics3931 Год назад

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

  • @Gfragakhs
    @Gfragakhs 4 месяца назад

    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 2 месяца назад

      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!"

  • @rainsmcacc
    @rainsmcacc Год назад

    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  Год назад

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

  • @gta_ishan
    @gta_ishan 2 месяца назад

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

    • @KAE00015
      @KAE00015 2 месяца назад

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

  • @spirit8878
    @spirit8878 Год назад

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

    • @L33bear
      @L33bear Год назад

      your token is wrong

  • @jacklondon2663
    @jacklondon2663 7 месяцев назад

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

    • @wetn
      @wetn 7 месяцев назад +3

      Yes

  • @XxprogamerezcerezxX
    @XxprogamerezcerezxX Год назад

    it sends me an empty message box

  • @robhopper5729
    @robhopper5729 Год назад

    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  Год назад

      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 10 месяцев назад

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

  • @xxlilnovaxx
    @xxlilnovaxx Год назад

    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 Год назад

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

    • @xxlilnovaxx
      @xxlilnovaxx Год назад

      @@RoganShorts2715 ok ill try it, thank you

  • @zaixyu
    @zaixyu Год назад

    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 Год назад

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

  • @beezy-3505
    @beezy-3505 5 месяцев назад

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

    • @SlimeyHD
      @SlimeyHD 4 месяца назад +1

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

  • @bezarwashere
    @bezarwashere 9 месяцев назад

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

    • @stijn_gamet
      @stijn_gamet 9 месяцев назад

      applicationGuildCommands not applicationGuildCommand

  • @fitzy121fitzgerald5
    @fitzy121fitzgerald5 10 месяцев назад

    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?

  • @aqfeet_clashroyale
    @aqfeet_clashroyale Год назад

    @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 7 месяцев назад +1

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

  • @Boxed-matt
    @Boxed-matt 4 месяца назад +1

    Hey where do you find the guild Id ??

    • @LogoSystemCG
      @LogoSystemCG 3 месяца назад

      this is your discord server ID

    • @theemeraldend4302
      @theemeraldend4302 2 месяца назад

      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

  • @midwesternlassalle
    @midwesternlassalle Год назад

    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

    • @midwesternlassalle
      @midwesternlassalle Год назад

      fixed it following me sending this, probably spoke too soon

  • @j0ppi
    @j0ppi Год назад

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

    • @tariqplays5826
      @tariqplays5826 2 месяца назад

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

  • @YourLocalPeanutButterEnjoyer
    @YourLocalPeanutButterEnjoyer 6 месяцев назад

    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 2 месяца назад +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 2 месяца назад

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

  • @tennlam4356
    @tennlam4356 8 месяцев назад

    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 8 месяцев назад

      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 2 месяца назад

      @@robotmercenary8844DUDE I LOVE YOU

    • @darkzy6950
      @darkzy6950 2 месяца назад

      @@robotmercenary8844saved me so much

  • @Zolac36
    @Zolac36 Год назад

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

    • @UnderCtrl
      @UnderCtrl  Год назад

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

  • @lukegilson2917
    @lukegilson2917 Год назад

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

  • @automhate
    @automhate 3 месяца назад +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'

  • @ImAlxer
    @ImAlxer 5 месяцев назад

    undefined value in guild id and user id wtf

  • @Sweat._.T
    @Sweat._.T Год назад

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

    • @UnderCtrl
      @UnderCtrl  Год назад +1

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

    • @Sweat._.T
      @Sweat._.T Год назад

      @@UnderCtrl alright thank you

  • @lukegilson2917
    @lukegilson2917 Год назад

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

  • @splashyreacts
    @splashyreacts Год назад

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

    • @UnderCtrl
      @UnderCtrl  Год назад +2

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

    • @splashyreacts
      @splashyreacts Год назад

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

  • @_MAGMI
    @_MAGMI Год назад

    why do we need the guild id ?

    • @UnderCtrl
      @UnderCtrl  Год назад +1

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

  • @Zerokopas
    @Zerokopas Год назад

    I have error method not allowed

    • @ralphwiggum1203
      @ralphwiggum1203 Год назад

      im getting this too
      ill update if i find a fix

  • @Zolac36
    @Zolac36 Год назад

    how to get the src file???

    • @UnderCtrl
      @UnderCtrl  Год назад

      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"

  • @Himanshupatel-ij3zq
    @Himanshupatel-ij3zq 10 месяцев назад

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

    • @UnderCtrl
      @UnderCtrl  10 месяцев назад

      That is probably because you have multiple terminals open

    • @Himanshupatel-ij3zq
      @Himanshupatel-ij3zq 10 месяцев назад

      @@UnderCtrl thanks I got solution from your discord.

  • @bendeguzbenkovics903
    @bendeguzbenkovics903 4 месяца назад

    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.

  • @Bluei2h
    @Bluei2h Год назад

    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 Год назад

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

    • @hamm3rman199
      @hamm3rman199 Год назад +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 Год назад +1

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

    • @kanlin2501
      @kanlin2501 Год назад

      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 Год назад

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

  • @hackerboomm.official
    @hackerboomm.official Год назад

    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 Год назад

      I solved the problem anyways

    • @immuchh
      @immuchh Год назад

      please help me with that as i have the same problem