Claim + Drop Roles with Buttons (Discord.js v14)

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

КОМЕНТАРІ • 44

  • @skadezy8487
    @skadezy8487 5 днів тому

    Thank you mate. I was having a difficult time understanding the docs, but u made it very clear so far.

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

    This is the best tutorial, I am a beginner at js and trust me this helped me in understanding the language so well

  • @radosawczuj1054
    @radosawczuj1054 Рік тому +6

    Something worth mentioning is that the bot's role should be moved to the top of the hierarchy of the server, for it to be able to assign and remove other roles.

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

    well, this channel is really underrated!

  • @Deleted-User-f7i
    @Deleted-User-f7i Рік тому +2

    It worked! I am so proud!

  • @que7244
    @que7244 9 місяців тому +1

    this is sick love it, i do want to ask how do you add it to a embeded message for OCD sake

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

    Followed it step by step but the interaction doesn't work, I also had to add "ActionRowBuilder, ButtonBuilder, ButtonStyle" to the discord.js import to even make the "sendmessage.js" file work.
    Is there any new or better way to do this?

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

    at 5:18 you say to add a new row for every 5 roles, could you show an example of that?

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

      In the first const with the roles make sure there is only 5 then create a second one if you have more then 5 then client should be set like this:
      client.on('ready', async (c) => {
      try {
      const channel = client.channels.cache.get('1091397837138432090')
      if (!channel) return;
      const row = new ActionRowBuilder();
      const row2 = new ActionRowBuilder();
      roles.forEach((role) => {
      row.components.push(
      new ButtonBuilder()
      .setCustomId(role.id)
      .setLabel(role.label)
      .setStyle(ButtonStyle.Primary),
      );
      });
      roles2.forEach((role) => {
      row2.components.push(
      new ButtonBuilder()
      .setCustomId(role.id)
      .setLabel(role.label)
      .setStyle(ButtonStyle.Primary),
      );
      });
      await channel.send({
      content: 'Select which ping roles you would like, press a second time to remove.',
      components: [row, row2]
      });

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

      @@TriLimitStudiostysm

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

    Also one more doubt, at 06:11, you said if we have other slash commands, then we should open curly brackets, so from where to where should the curly brackets be?

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

      I know this is an old comment but I'll give an answer for those who had this question as well,
      If you also have old slash commands from this series or any other,
      What I did is just put the code for the roles at top (when I put it bottom it didn't work for some reason) and it should work
      _client.on("interactionCreate", async (interaction) => {_
      _if (interaction.isButton()) {_
      _// Your roles code_
      _}_
      _// Other slash commands_
      _});_

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

      @@joybumbershoot omg thank you so much i had so much trouble trying to find out why my code wasn't working

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

      @@supercutswft No problem glad I could help

  • @theepichour92
    @theepichour92 2 місяці тому

    I'm getting this error :c "ReferenceError: guild is not defined"

  • @ZeroBlue0956
    @ZeroBlue0956 11 місяців тому +1

    The code works and no bugs show up but the message isnt sent

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

    I had a small doubt here , at 6:12 , when you mentioned that if you have / commands , add them in the { } , Can you explain that thing in a bit detail please , Been following the guide from the start , and I have every / command in the code , from the previous video's , Thank you

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

      If you don't have a command handler and you want to handle slash commands using the interactionCreate event listener, then you'd have to specifically handle your button interactions within those curly { } brackets. I realized now looking back at the video, I should've said something like "If you have your slash command logic within this same interactionCreate event listener, you need to add the button handling code in the { } so it's kind of its own scope and separate from the slash commands logic".

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

      Oh , so what u meant was to add only the button interactions within the { } , at first I thought you meant like the whole / commands code , and I in fact did that , and got confused , so wanted to ask you about that . Thank you for the help
      @@UnderCtrl

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

      Hey , sorry to be back at this again , But I seem to have been a little lost with this certain thing , the code runs fine to the part where the button command is not there , but when I paste it there ( previously cut from here ) , the bot begins to crash even on those command , which were running fine earlier. Can you please help me out here again , thank u .
      @@UnderCtrl

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

    amazing,, you are the best!

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

    Although it's going to be built-in on Discord, good work.
    Can you make videos about ES6 module with classes?

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

      Thanks. I’ll cover ES6 modules in my JavaScript series

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

      @@UnderCtrl Thank you so much, I will waiting for it 👍🏻.

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

    i went to the link you have in your status in discord and i got rickrolled lmao

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

    Is it possible to set the role assignment message as an embed and use emojis as the reaction button? Kind of similar to the Carl bot to where the emoji button is highlighted if that user has that role and won't send a message to the channel if the user assigns themselves that role? Sorry hard to explain without showing a picture lol

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

      Hi. That’s certainly possible, and I’d suggest joining my Discord so we can help you from there :) ctrl.lol/discord

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

    pls Tutorial for more as 5 Buttons pls

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

    I had a doubt that I did not understand what did you say for more than 5 roles. Then what to do? 05:12

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

      In the first const with the roles make sure there is only 5 then create a second one if you have more then 5 then client should be set like this:
      client.on('ready', async (c) => {
      try {
      const channel = client.channels.cache.get('1091397837138432090')
      if (!channel) return;
      const row = new ActionRowBuilder();
      const row2 = new ActionRowBuilder();
      roles.forEach((role) => {
      row.components.push(
      new ButtonBuilder()
      .setCustomId(role.id)
      .setLabel(role.label)
      .setStyle(ButtonStyle.Primary),
      );
      });
      roles2.forEach((role) => {
      row2.components.push(
      new ButtonBuilder()
      .setCustomId(role.id)
      .setLabel(role.label)
      .setStyle(ButtonStyle.Primary),
      );
      });
      await channel.send({
      content: 'Select which ping roles you would like, press a second time to remove.',
      components: [row, row2]
      })

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

      @@TriLimitStudios thanks brooooo thank you!

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

      @@prithvibiswal69 Np

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

    2:46 I cant run the bot because it says Cannot read properties of undefined (reading 'get') pls help

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

      While I haven't watched the video yet, it screams to me that you're probably missed initializing a collection/list/array

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

    Thanks for this useful tutorial

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

    I have this in my bot im working on using your event handler, and I have transitioned it over pretty well, but I cant get the bot to stop posting the message every single time it starts. Is there a simple way to do this that im missing?

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

      add "//" before the command and it should ignore it, later when u want to add another, just remove the "//" and edit the command and you're good to go (im not sure if this works but this is what I would do)

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

    Thanks but it says "Error" and that im 'Missing Permissions'

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

      To fix that error you have to drag the role that your discord bot has higher than the role you are trying to give to the user.

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

    tysm!

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

    thx!!!!!!!!!!!!!!!!!