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

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 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 15 วันที่ผ่านมา

    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)

    • @ImagineGamingPlay
      @ImagineGamingPlay  7 หลายเดือนก่อน +8

      Thank you! Atleast someone remembers

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

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

  • @Glitchwar7
    @Glitchwar7 7 หลายเดือนก่อน +1

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

  • @TheRealKyuOFC
    @TheRealKyuOFC 9 หลายเดือนก่อน +1

    Waiting for next part🎉

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

  • @AlluXD
    @AlluXD 9 หลายเดือนก่อน +1

    Holy shit bro came back

  • @zolite7213
    @zolite7213 5 หลายเดือนก่อน +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.

  • @im_andrei1010
    @im_andrei1010 9 หลายเดือนก่อน +2

    GUYS HES BACK

  • @boutaflika5519
    @boutaflika5519 6 หลายเดือนก่อน +3

    here u go sir.

    • @RohanPlayZ_YT
      @RohanPlayZ_YT 6 หลายเดือนก่อน +1

      I feel bad for you..

    • @taimialia
      @taimialia 6 หลายเดือนก่อน

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

    • @ImagineGamingPlay
      @ImagineGamingPlay  5 หลายเดือนก่อน +1

      My bad

  • @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 7 วันที่ผ่านมา

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

  • @TheAntinity
    @TheAntinity 9 หลายเดือนก่อน +1

    bro came alive

  • @DemonX82
    @DemonX82 3 หลายเดือนก่อน

    Thanks, you made it looks easy

  • @GamingCoderzX
    @GamingCoderzX 9 หลายเดือนก่อน

    My mans backkkkkkk! Les goooo

  • @DiscordTricks
    @DiscordTricks 9 หลายเดือนก่อน +1

    He is back

  • @Discord_users
    @Discord_users หลายเดือนก่อน

    I made my own bot! Thank you!

  • @celxsth
    @celxsth 9 หลายเดือนก่อน +1

    Yooo bro came back

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

  • @matute_penzotti
    @matute_penzotti 7 หลายเดือนก่อน

    omgg bro tyy i need this a lot

  • @CodeCrazyX
    @CodeCrazyX 5 หลายเดือนก่อน

    Thank you a good video keep up

  • @misbah.m
    @misbah.m 9 หลายเดือนก่อน +2

    slayyyy skay 💅

  • @MashrafiYT
    @MashrafiYT 9 หลายเดือนก่อน +2

    W

  • @boutaflika5519
    @boutaflika5519 6 หลายเดือนก่อน +2

    ooooraaa

  • @CharlesShorts
    @CharlesShorts 6 หลายเดือนก่อน

    Amazing tutorial

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

  • @faaxultimate7695
    @faaxultimate7695 2 หลายเดือนก่อน

    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

    • @ImagineGamingPlay
      @ImagineGamingPlay  หลายเดือนก่อน

      Have you tried refreshing your client?

  • @nafiskamalniloy4402
    @nafiskamalniloy4402 6 หลายเดือนก่อน

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

  • @SkyfireGamez
    @SkyfireGamez 9 หลายเดือนก่อน +1

    i didnt hear you get rebooted man

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

  • @chemreal
    @chemreal 9 หลายเดือนก่อน +1

    bro who got his reboot card 💀

  • @spaceuniversity7448
    @spaceuniversity7448 9 หลายเดือนก่อน +1

    Post more i need you

  • @Discord_users
    @Discord_users หลายเดือนก่อน

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

    • @Discord_users
      @Discord_users 15 วันที่ผ่านมา

      Hey can I code a bot with you?

  • @NotSar
    @NotSar หลายเดือนก่อน +1

    when are you coming back

    • @ImagineGamingPlay
      @ImagineGamingPlay  หลายเดือนก่อน +1

      Very soon

    • @NotSar
      @NotSar หลายเดือนก่อน

      @@ImagineGamingPlay W

  • @Liyahrts
    @Liyahrts 5 หลายเดือนก่อน

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

    • @Liyahrts
      @Liyahrts 5 หลายเดือนก่อน

      using ur bot ofc

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

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

  • @fish_fnf
    @fish_fnf 9 หลายเดือนก่อน +1

    Did someone press your start button?

  • @Noodles6000
    @Noodles6000 9 หลายเดือนก่อน +1

    Igp revived discord bot help

  • @angelzinhah4519
    @angelzinhah4519 6 หลายเดือนก่อน

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

  • @za234v8
    @za234v8 6 หลายเดือนก่อน

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

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

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

  • @curlzncrush
    @curlzncrush 9 หลายเดือนก่อน

    The king is back!

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

  • @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 หลายเดือนก่อน

    IT SAYS INSTALL REPLITS NODE TOOLS

  • @angelzinhah4519
    @angelzinhah4519 9 หลายเดือนก่อน

    BRO WHERE WERE YOU

  • @goldtequila_.
    @goldtequila_. 8 หลายเดือนก่อน

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

  • @shivangimishra9142
    @shivangimishra9142 8 หลายเดือนก่อน

    ❤❤

  • @00_Hacker
    @00_Hacker 6 หลายเดือนก่อน

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

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

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

  • @AljoBerg
    @AljoBerg 9 หลายเดือนก่อน +2

    Yowtf

  • @Blurrzed
    @Blurrzed 5 หลายเดือนก่อน

    what is the software you use to code?

  • @shivangimishra9142
    @shivangimishra9142 3 หลายเดือนก่อน

    Hi

  • @YellowARMY_gtag
    @YellowARMY_gtag 3 หลายเดือนก่อน

    PASTE BIN>>>

  • @clonetrooper23
    @clonetrooper23 7 หลายเดือนก่อน

    7:40

  • @mayatheshark
    @mayatheshark 4 หลายเดือนก่อน

    not working

  • @ChicagoRoleplayCommunity
    @ChicagoRoleplayCommunity 9 หลายเดือนก่อน

    Which discord.js should we use?

  • @dragon-slayer27
    @dragon-slayer27 9 หลายเดือนก่อน

    Bro took a whole lifetime to post

  • @The_kidscartoon
    @The_kidscartoon 9 หลายเดือนก่อน +1

    First comment. Likeeee

  • @Universe_Error
    @Universe_Error 7 หลายเดือนก่อน

    idk why but this is bugging my code

  • @boutaflika5519
    @boutaflika5519 6 หลายเดือนก่อน

    imagineeee

  • @Discord_users
    @Discord_users หลายเดือนก่อน

    But

  • @nasab8781
    @nasab8781 9 หลายเดือนก่อน +1

    👋👋❤❤

  • @NotSoZub2010
    @NotSoZub2010 9 หลายเดือนก่อน

    I am fast as fk boiis

  • @goodboyneon
    @goodboyneon 9 หลายเดือนก่อน

    YOU ALIVENED FROM THE DEAD WTF

  • @augustfeeling
    @augustfeeling 9 หลายเดือนก่อน

    speed

  • @SAVENGE_XT
    @SAVENGE_XT 9 หลายเดือนก่อน +1

    firstt

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

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

    • @ImagineGamingPlay
      @ImagineGamingPlay  3 หลายเดือนก่อน

      Have you fixed it or still need help?

  • @celxsth
    @celxsth 9 หลายเดือนก่อน +1

    Yooo bro came back