How to make Slash Commands for your Discord Bot (Discord.js)

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024
  • Learn how to make Slash Commands for your bot in Discord.js!
    In this bit, we go through the basics of Slash Commands like registering them, replying and more. I've been trying the "explain more and copy less" strategy so you can actually learn a thing or two while watching the video.
    I've been trying so long to finish this video as soon as I can but always winded up in some irritatingly circumstances that would prevent me from working on it.
    Watch the Beginner's video: • How to make a Discord ...
    If you feel like you're stuck or something isn't working, don't hesitate to join my Discord server. We'd be happy to assist you!
    / discord
    Loving my content? want to support?
    How about joining my channel membership, you'll receive amazing perks, and I would be able to brew some coffee too.
    / @imaginegamingplay
    And I'll be seeing you in the next video. Let's hope it's not another year.

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

  • @HaneeshPediredla
    @HaneeshPediredla 12 дней назад

    Out of 100 tutorials I watched this is the only one that explains clearly!! You earned yourself a sub man!!

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

    happy 18th bday dude! (i was watching the embed tutorial when you said your bday and i realised im watching on your 18th haha)

  • @thamtom3856
    @thamtom3856 9 месяцев назад +4

    Big W! Looking forward for the part 2 and upcoming future videos. Keep it up mate

  • @oyepriyansh
    @oyepriyansh 9 месяцев назад +18

    Bros Comback 👀

  • @Bruinebies
    @Bruinebies 9 месяцев назад +4

    Yo, you are back on youtube :D

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

    Haven't seen this name in a while... Welcome back IGP.

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

    The legend finally came back, a big W fr

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

    Thank you for making this video! This was super helpful!

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

    My mans backkkkkkk! Les goooo

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

    Holy shit bro came back

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

    Waiting for next part🎉

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

    “Hey, I hope you are doing well. I just wanted to say that over the past few months, our conversations have really meant a lot to me and I’ve developed feelings for you. I enjoy spending time with you and I love how you make me feel when I’m around you. I’m telling you all this because I care about you and I think you deserve to know the truth. So I just want you to know that my feelings for you are real and I want you to think about it as well.”

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

    He is back

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

    GUYS HES BACK

  • @KikoMT
    @KikoMT 4 месяца назад +2

    For some reason when I execute the code in the shell, some error pops up mentioning "Cannot read properties of undefined (reading 'setToken')" how can I fix this issue

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

      fixed it or still?

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

    i keep getting to @4:30 where i run the "node name-of-file.js" and it tells me "TypeError: REST is not a constructor" yet this is what my code looks like
    const { REST, Routes } = require("discord.js");
    //Info needed for slash commands
    const botID = "here i have my bot ID, ignore this part";
    const serverID = "here i have my server ID, ignore this part";
    const botToken = process.env.token;
    const rest = new REST().setToken(botToken);
    const slashRegister = async () => {
    try {
    await rest.put(Routes.applicationGuildCommands(botID, serverID), {
    body: [
    {
    name: "ping",
    description: "just ping command, lol."
    }
    ]
    });
    } catch (error) {
    console.log(error);
    }
    };
    slashRegister();
    thoughts?

    • @ImagineGamingPlay
      @ImagineGamingPlay  3 месяца назад +1

      Sorry for ignoring, are you using the latest discord.js version? If you don't know how to check, do let me know.

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

      @@ImagineGamingPlay ~/AttachedSwelteringLearning$ node slash-deploy.js
      node:internal/modules/cjs/loader:1146
      throw err;
      ^
      Error: Cannot find module 'discord.js'
      Require stack:
      - /home/runner/AttachedSwelteringLearning/slash-deploy.js
      at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
      at Module._load (node:internal/modules/cjs/loader:984:27)
      at Module.require (node:internal/modules/cjs/loader:1231:19)
      at require (node:internal/modules/helpers:179:18)
      at Object. (/home/runner/AttachedSwelteringLearning/slash-deploy.js:1:26)
      at Module._compile (node:internal/modules/cjs/loader:1369:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
      at Module.load (node:internal/modules/cjs/loader:1206:32)
      at Module._load (node:internal/modules/cjs/loader:1022:12)
      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [ '/home/runner/AttachedSwelteringLearning/slash-deploy.js' ]
      }(
      this is the error i get on the same step

    • @artman3
      @artman3 3 месяца назад +1

      im also getting the same problem, have you found a fix?
      edit:
      i think i fixed it, take off the "()" in
      const rest = new REST().setToken(botToken);
      so it should be
      const rest = new REST.setToken(botToken);
      but for some reason it doesnt show it on discord, i even made prefix command and nothing would print

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

      @@artman3 im actually just now seeing his reply.. fuck me. i havent found a fix btw, but as he said to me check to see if you're using the latest discord.js version since that might be the root of our issues

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

      @@ImagineGamingPlay just now seeing your reply 😭 im not 100% sure if i am or not, ill get back to you on whether or not it fixes the issue.

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

    Thanks, you made it looks easy

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

    Yooo bro came back

  • @Discord_users
    @Discord_users Месяц назад

    I made my own bot! Thank you!

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

    omgg bro tyy i need this a lot

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

    Thank you a good video keep up

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

    bro came alive

  • @boutaflika5519
    @boutaflika5519 6 месяцев назад +3

    here u go sir.

    • @RohanPlayZ_YT
      @RohanPlayZ_YT 6 месяцев назад +1

      I feel bad for you..

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

      fr feel bad that the creator didn't reply or pinged ur message

    • @ImagineGamingPlay
      @ImagineGamingPlay  5 месяцев назад +1

      My bad

  • @misbah.m
    @misbah.m 9 месяцев назад +2

    slayyyy skay 💅

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

    Not sure if anyone will see this, but for some reason it keeps saying something alone the lines of REST isn't valid or smthin, I genuinely can't do anything because rest wont work. Any advice?

    • @ImagineGamingPlay
      @ImagineGamingPlay  Месяц назад

      You need to be a little more specific about the error

    • @lily_chann
      @lily_chann 4 дня назад

      ​@@ImagineGamingPlay REST is not a constructor is what shows up

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

    Amazing tutorial

  • @boutaflika5519
    @boutaflika5519 6 месяцев назад +2

    ooooraaa

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

    This is a well paced, all rounded video, however I would like to mention that the lack of 4k really ruining the experience for me, nevertheless, I will hesitate from calling this video bad because of the pros I mentioned above. Looking forward to see more videos, but the next time with 4k.
    Thank you for your understanding.

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

    Bro remembered his youtube password

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

    It says my token is not present when I tried to run the command in shell. How do I fix this?
    Edit: now it says discordapi error 401 unauthorized
    Edit 2: ok it says my token is invalid/unexpected when I type node slash-deploy.js

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

      have you fixed it yet

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

      I'm having the same issue, any help would be appreciated

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

      @terracottasucks it means your token is invalid in the security tab

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

    W

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

    The king is back!

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

    i didnt hear you get rebooted man

  • @ZENUX_EDITS
    @ZENUX_EDITS 9 месяцев назад +4

    Who tf revived you

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

      Found my reboot card

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

      @@ImagineGamingPlay nahhhh bro you're literally our careless father in bot development you thaught as the most basic things and went for milk and we learnt everything advanced ourselves. Joining your servers feels like nostalgia. Sending code with token and using that one dog bot (chiku was the name ig) tag system to get code like "start" tag and other tags for commands' code.
      Started from copying others code from your server to teaching others bot development. I've come a long way (now it's boring but I wanna restart).
      Love from India buddy ❤️

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

    Did someone press your start button?

  • @NotSar
    @NotSar Месяц назад +1

    when are you coming back

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

    Post more i need you

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

    can u make a video with a slash command with embed having options?

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

    bro who got his reboot card 💀

  • @faaxultimate7695
    @faaxultimate7695 Месяц назад

    not sure if anyone will see this, but for some reason my slash command simply just doesn't appear. my bot is online, and it is in my server. but the slash command doesnt show

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

    Igp revived discord bot help

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

    shell says that "TypeError: REST is not a constructor", what do i do to fix?

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

      Sorry for ignoring, are you using the latest discord.js version? If you don't know how to check, do let me know.

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

      @@ImagineGamingPlay how do you?

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

      @Zachary_24 Go to package.json, and there you'll see a line which goes something like "discord.js": version, from there you can see the version. (like 14.x.y is v14)

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

      @@ImagineGamingPlay mine is 1.0.0

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

      @@MrGamerBoyYTOrg you're seeing the wrong line

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

    First comment. Likeeee

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

    could u make a video next on how to make reaction roles?

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

      using ur bot ofc

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

    Eii, so I was wondering. Coul you please remake the first videos? The codes aren't working anymore

  • @Discord_users
    @Discord_users Месяц назад

    Can you make a tutorial of how to make your bot be seen on the bot directory?

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

    IT SAYS INSTALL REPLITS NODE TOOLS

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

    I keep getting an error called "REST is not a constructor at Object" does anyone know how to fix it?

  • @kaydencaisley2394
    @kaydencaisley2394 5 месяцев назад +1

    BRO 3:38 TELL ME WHAT TO DO LIKE UR JUST GOIN BAM BAM QUICK apart from that good work sorry

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

    Hey I don't know what is happening but for require("discord.js") it says "File is a CommonJS module; it may be converted to an ES module." I am really confused

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

      It also says cannot find module

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

      Your initial comment is just a warning. For your second issue, you don't have discord.js installed most likely

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

      @@ImagineGamingPlay thanks but I have it installed

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

      Keeps happening to me aswell, anyone know what to do?

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

      @@MuddyIsCool i some how fixed it

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

    what is the software you use to code?

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

    BRO WHERE WERE YOU

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

    Yo why taking so long for a video create more videos
    Can you explain how to code our bots like without checking tutorials os it possible ?

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

    so for me it says "REST is not a constructor" so maybe i need to update my discord.js version. how do i do that without fucking up the codes?

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

      nvm i've done it but idk if my codes still work like before. It's saying "ReadableStream is not defined"

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

      @@kodzukennnnn Your node.js is outdated. are you using an old repl project perhaps?

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

      @@ImagineGamingPlay nope it’s new and i stopped using replit cause they told me that it’s not that safe so don’t worry! thanks for answering
      if you want more info about replit i could dm you on discord

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

    how to download discord.js v14 on replit. It only shows v14.14.1

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

    Which discord.js should we use?

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

    not working

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

    How to make, that the bot loggs into an Fortnite account?

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

    I cant use spaces or Capitals in my Command name anyone help me?

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

      You cant use them, for example you cant do “/Ping Me” but you can do “/ping-me”

    • @Kaiser_Playz
      @Kaiser_Playz Месяц назад +1

      @@stilry I have seen multiple commands use spaces though

    • @stilry
      @stilry Месяц назад

      @@Kaiser_Playz might be like special coding or something

    • @ImagineGamingPlay
      @ImagineGamingPlay  Месяц назад

      @@Kaiser_Playz Those are called sub commands

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

    it says Rest is not a Constructor how the hell do we fix that??

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

      I'd need to see your code for that

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

      @@ImagineGamingPlay So it no longer does that but it wont do a command still after running into no errors.

  • @mychannel583
    @mychannel583 Месяц назад

    how to fix
    error message
    ReferenceError: ReadableStream is not defined
    at Object. (/home/runner/bot/node_modules/undici/lib/web/fetch/response.js:530:3)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object. (/home/runner/bot/node_modules/undici/lib/web/fetch/index.js:11:5)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    my code
    const { REST, Routes } = require("discord.js")
    //info
    const botID = "1270926735382413343"
    const serverID = "1270933837068898305"
    const botToken = process.env.token
    const rest = new REST().setToken(botToken)
    const slashRegister = async () => {
    try {
    await rest.put(Routes.applicationGuildCommands(botID, serverID), {
    body: [
    {
    name: "ping",
    description: "Replies with pong!"
    }
    ]
    })
    } catch (error) {
    console.log(error)
    }
    }
    slashRegister();

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

    PASTE BIN>>>

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

    Hi

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

    ❤❤

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

    YOU ALIVENED FROM THE DEAD WTF

  • @Discord_users
    @Discord_users Месяц назад

    But

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

    Yowtf

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

    7:40

  • @dragon-slayer27
    @dragon-slayer27 9 месяцев назад

    Bro took a whole lifetime to post

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

    idk why but this is bugging my code

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

    I am fast as fk boiis

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

    👋👋❤❤

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

    firstt

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

    imagineeee

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

    Nvm

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

    Igp, can i please get unbanned on your server? I had been banned a long time ago just because of joking.

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

    speed

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

    z

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

    goofy ah voice

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

    I dont use these AI voices I don't trust them look up No Text to Speach and he will help you his a real person and isn't a AI voice that says get me to this like and I'll do a voice reveal

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

    Can you explain how to fix this?
    ExpectedConstraintError > s.string.regex
    Invalid string format
    Expected: expected /^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u.test(expected) to be true
    Received:
    | 'ping'

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

    Yooo bro came back