Register and Run Slash Commands (Discord.js v14)

Поділитися
Вставка
  • Опубліковано 13 гру 2024

КОМЕНТАРІ • 222

  • @UnderCtrl
    @UnderCtrl  2 роки тому +14

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

    • @Leafstuff
      @Leafstuff Рік тому

      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 Рік тому

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

    • @TheFirstDEv1L
      @TheFirstDEv1L 3 місяці тому

      ​@@Leafstuff.

  • @spl1c3
    @spl1c3 10 місяців тому +43

    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.

  • @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 Рік тому +10

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

  • @aiwanano6507
    @aiwanano6507 Рік тому +18

    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 Рік тому +3

      thank you you beautiful man

    • @Shrey_Yash
      @Shrey_Yash 5 місяців тому +1

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

    • @amysgamingadventures
      @amysgamingadventures 5 місяців тому

      Thank you! This helped!

    • @JalalOsamaa
      @JalalOsamaa 3 місяці тому

      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 3 місяці тому

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

  • @k0r7ex
    @k0r7ex 2 роки тому +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.

  • @Arshlow
    @Arshlow Рік тому +3

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

  • @josephmcnew34
    @josephmcnew34 Рік тому +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🤘

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

  • @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 3 місяці тому

    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.

  • @oscarthroedsson1410
    @oscarthroedsson1410 Рік тому

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

  • @abdielcuevas4281
    @abdielcuevas4281 8 місяців тому +4

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

  • @Lively_Shorts-q7h
    @Lively_Shorts-q7h Рік тому

    you are explaining very good!

  • @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 10 місяців тому +1

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

    • @EdgeFPS
      @EdgeFPS 7 місяців тому

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

  • @nerusnf
    @nerusnf 3 місяці тому +1

    Thank you!

  • @aveyan23
    @aveyan23 10 місяців тому

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

    • @UnderCtrl
      @UnderCtrl  10 місяців тому +1

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

  • @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 Рік тому +1

      I tried this but still keep getting an error

    • @Likeable_Emmec
      @Likeable_Emmec 5 місяців тому

      My saviour!

  • @BeelBellX
    @BeelBellX Рік тому

    Thank you very much, it helped me a lot.

  • @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 8 місяців тому +2

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

  • @josephmcnew34
    @josephmcnew34 Рік тому

    this is awesome ! thanks

  • @NotPensive
    @NotPensive 6 місяців тому +2

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

  • @MetaIsRG4L
    @MetaIsRG4L Рік тому +5

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

  • @skcarti
    @skcarti Рік тому

    Thank you! you recieved a subscriber

  • @Reedfender
    @Reedfender Рік тому +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

  • @the-name-is-mocha9570
    @the-name-is-mocha9570 10 місяців тому +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?

  • @bsizzle1352
    @bsizzle1352 9 місяців тому +4

    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

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

  • @dapesaDVD
    @dapesaDVD Рік тому

    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  Рік тому +1

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

  • @Inactivebiiiiiiiiit
    @Inactivebiiiiiiiiit 2 роки тому +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  2 роки тому

      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.

  • @kxhna
    @kxhna Рік тому +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 Рік тому +1

      Same here

    • @stijn_gamet
      @stijn_gamet Рік тому +2

      applicationGuildCommands not applicationGuildCommand

  • @smartbox943
    @smartbox943 3 місяці тому

    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

  • @SFDark
    @SFDark 7 місяців тому +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.

  • @darksantaeu
    @darksantaeu Рік тому +1

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

  • @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 Рік тому

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

    • @immuchh
      @immuchh Рік тому

      @@hredd9299 ^

    • @jacobymryoutube
      @jacobymryoutube 6 місяців тому

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

  • @infini667
    @infini667 6 місяців тому

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

    • @UnderCtrl
      @UnderCtrl  6 місяців тому

      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 6 місяців тому

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

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

  • @Rezgc_
    @Rezgc_ 3 місяці тому

    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

  • @weightliftingcalisthenics3931

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

  • @LuxTalks-br9tx
    @LuxTalks-br9tx 2 місяці тому

    The slash commands aren't in my server idk why

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

  • @thiagolore7045
    @thiagolore7045 Рік тому +1

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

  • @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 8 місяців тому

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

  • @yukkiiflores236
    @yukkiiflores236 Місяць тому

    Wish you could slow down more and explain more of whats going on

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

  • @Marlon-ly4ui
    @Marlon-ly4ui 5 місяців тому

    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

  • @j0ppi
    @j0ppi Рік тому

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

    • @tariqplays5826
      @tariqplays5826 5 місяців тому

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

  • @alexaligator
    @alexaligator 8 місяців тому

    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?

    • @WasEzXD
      @WasEzXD Місяць тому +1

      in your src/register-commands.js
      replace this
      await rest.put(
      Routes.applicationGuildCommands(
      process.env.CLIENT_ID,
      process.env.GUILD_ID)
      { body: commands }
      );
      put this instead
      await rest.put(
      Routes.applicationCommands(process.env.CLIENT_ID),
      { body: commands }
      );
      it should be fixed

  • @fitzy121fitzgerald5
    @fitzy121fitzgerald5 Рік тому

    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?

  • @thatoneweirdkidthatyoudisl6723
    @thatoneweirdkidthatyoudisl6723 5 місяців тому

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

  • @automhate
    @automhate 6 місяців тому +2

    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'

    • @OrangeRoot
      @OrangeRoot 5 місяців тому +2

      Thx bro!

    • @RenegadeDan
      @RenegadeDan 2 місяці тому +1

      Dude no lie I scoured my code trying to figure this out... You're a legend 💯

  • @grimgaunt.
    @grimgaunt. Рік тому

    Thank you~

  • @HuyMusicYTC
    @HuyMusicYTC Рік тому

    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

  • @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?

  • @misty5130
    @misty5130 7 місяців тому

    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  6 місяців тому +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 6 місяців тому

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

  • @Pi_Maaster
    @Pi_Maaster Рік тому

    you are the best

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

  • @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 Рік тому

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

  • @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 Рік тому

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

  • @ik4k
    @ik4k 6 місяців тому

    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 6 місяців тому

      @UnderCtr

    • @Day_Tac
      @Day_Tac 4 місяці тому

      @Under Cntrl

  • @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 10 місяців тому

      I have that same problem, havent figured it out yet

    • @ilovelampadaire
      @ilovelampadaire 6 місяців тому

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

  • @gooseman4776
    @gooseman4776 10 місяців тому +1

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

    • @LIL_13EN
      @LIL_13EN 10 місяців тому +1

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

    • @zynphxz1694
      @zynphxz1694 8 місяців тому

      @@LIL_13EN you saved me bro

  • @DannyCheezits
    @DannyCheezits Рік тому

    any idea why each command gets registered twice indentically?

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

  • @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 Рік тому +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

  • @PADELAOSGI
    @PADELAOSGI 11 місяців тому

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

  • @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);

  • @gta_ishan
    @gta_ishan 5 місяців тому

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

    • @kaijewl2
      @kaijewl2 5 місяців тому

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

  • @roto2134
    @roto2134 Рік тому +1

    how to remove a registered slash command ?

  • @Fragakhss
    @Fragakhss 7 місяців тому

    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 5 місяців тому

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

  • @beezy-3505
    @beezy-3505 8 місяців тому

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

    • @SlimeyHD
      @SlimeyHD 7 місяців тому +1

      I got it too and adding a semicolon behind the line with the setToken function fixed 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 10 місяців тому +1

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

  • @mollywater8715
    @mollywater8715 11 місяців тому

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

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

  • @YourLocalPeanutButterEnjoyer
    @YourLocalPeanutButterEnjoyer 10 місяців тому

    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 5 місяців тому +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 5 місяців тому

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

  • @tennlam4356
    @tennlam4356 11 місяців тому

    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 11 місяців тому

      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 5 місяців тому

      @@robotmercenary8844DUDE I LOVE YOU

    • @darkzy6950
      @darkzy6950 5 місяців тому

      @@robotmercenary8844saved me so much

  • @Florianbwg
    @Florianbwg 10 місяців тому

    how do i get the design like you?

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

  • @TdogThePog2015
    @TdogThePog2015 9 місяців тому

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

  • @jacklondon2663
    @jacklondon2663 10 місяців тому

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

    • @wetn
      @wetn 10 місяців тому +3

      Yes

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

  • @ふじたゆうま
    @ふじたゆうま Рік тому

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

    • @Rezgc_
      @Rezgc_ 3 місяці тому

      same, did u fix?

  • @bezarwashere
    @bezarwashere Рік тому

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

    • @stijn_gamet
      @stijn_gamet Рік тому

      applicationGuildCommands not applicationGuildCommand

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

  • @Boxed-matt
    @Boxed-matt 7 місяців тому +1

    Hey where do you find the guild Id ??

    • @LogoSystemCG
      @LogoSystemCG 6 місяців тому

      this is your discord server ID

    • @theemeraldend4302
      @theemeraldend4302 5 місяців тому

      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

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

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

  • @lukegilson2917
    @lukegilson2917 Рік тому

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

  • @XxprogamerezcerezxX
    @XxprogamerezcerezxX Рік тому

    it sends me an empty message box

  • @justecho5760
    @justecho5760 9 місяців тому

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

  • @Zerokopas
    @Zerokopas Рік тому

    I have error method not allowed

  • @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 Рік тому

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

    • @UnderCtrl
      @UnderCtrl  Рік тому

      That is probably because you have multiple terminals open

    • @Himanshupatel-ij3zq
      @Himanshupatel-ij3zq Рік тому

      @@UnderCtrl thanks I got solution from your discord.

  • @_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

  • @ImAlxer
    @ImAlxer 8 місяців тому

    undefined value in guild id and user id wtf

  • @lukegilson2917
    @lukegilson2917 Рік тому

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

  • @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)

  • @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!

  • @twojmruczus
    @twojmruczus Рік тому

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