Why doesn't kicking people work using discord.js









up vote
1
down vote

favorite












 const Discord = require("discord.js"),
bot = new Discord.Client();
let pre = "?"
bot.on("message", async msg =>
var msgArray = msg.content.split(" ");
var args = msgArray.slice(1);
var prisonerRole = msg.guild.roles.find("name", "Prisoner");
let command = msgArray[0];
if (command == `$preroll`)
if (!msg.member.roles.has(prisonerRole.id))
roll = Math.floor(Math.random()*6)+1;
msg.reply(`You rolled a $roll`)
else
msg.reply(`HaHa NOOB, you're in prison you don't get priveleges!`)


if (command == `$prekick`)
)
bot.login("token").then(function()
console.log('Good!')
, function(err)
console.log('Still good, as long as the process now exits.')
bot.destroy()
)


Everything works except actually kicking the person. The message sends nut it doesn't kick people. For example, when I type in ?kick @BobNuggets#4576 inactive, it says
@rishabhase has kicked @BobNuggets
Reason: inactive


But it doesn't actually kick the user, which is weird, can you help me?










share|improve this question

























    up vote
    1
    down vote

    favorite












     const Discord = require("discord.js"),
    bot = new Discord.Client();
    let pre = "?"
    bot.on("message", async msg =>
    var msgArray = msg.content.split(" ");
    var args = msgArray.slice(1);
    var prisonerRole = msg.guild.roles.find("name", "Prisoner");
    let command = msgArray[0];
    if (command == `$preroll`)
    if (!msg.member.roles.has(prisonerRole.id))
    roll = Math.floor(Math.random()*6)+1;
    msg.reply(`You rolled a $roll`)
    else
    msg.reply(`HaHa NOOB, you're in prison you don't get priveleges!`)


    if (command == `$prekick`)
    )
    bot.login("token").then(function()
    console.log('Good!')
    , function(err)
    console.log('Still good, as long as the process now exits.')
    bot.destroy()
    )


    Everything works except actually kicking the person. The message sends nut it doesn't kick people. For example, when I type in ?kick @BobNuggets#4576 inactive, it says
    @rishabhase has kicked @BobNuggets
    Reason: inactive


    But it doesn't actually kick the user, which is weird, can you help me?










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











       const Discord = require("discord.js"),
      bot = new Discord.Client();
      let pre = "?"
      bot.on("message", async msg =>
      var msgArray = msg.content.split(" ");
      var args = msgArray.slice(1);
      var prisonerRole = msg.guild.roles.find("name", "Prisoner");
      let command = msgArray[0];
      if (command == `$preroll`)
      if (!msg.member.roles.has(prisonerRole.id))
      roll = Math.floor(Math.random()*6)+1;
      msg.reply(`You rolled a $roll`)
      else
      msg.reply(`HaHa NOOB, you're in prison you don't get priveleges!`)


      if (command == `$prekick`)
      )
      bot.login("token").then(function()
      console.log('Good!')
      , function(err)
      console.log('Still good, as long as the process now exits.')
      bot.destroy()
      )


      Everything works except actually kicking the person. The message sends nut it doesn't kick people. For example, when I type in ?kick @BobNuggets#4576 inactive, it says
      @rishabhase has kicked @BobNuggets
      Reason: inactive


      But it doesn't actually kick the user, which is weird, can you help me?










      share|improve this question













       const Discord = require("discord.js"),
      bot = new Discord.Client();
      let pre = "?"
      bot.on("message", async msg =>
      var msgArray = msg.content.split(" ");
      var args = msgArray.slice(1);
      var prisonerRole = msg.guild.roles.find("name", "Prisoner");
      let command = msgArray[0];
      if (command == `$preroll`)
      if (!msg.member.roles.has(prisonerRole.id))
      roll = Math.floor(Math.random()*6)+1;
      msg.reply(`You rolled a $roll`)
      else
      msg.reply(`HaHa NOOB, you're in prison you don't get priveleges!`)


      if (command == `$prekick`)
      )
      bot.login("token").then(function()
      console.log('Good!')
      , function(err)
      console.log('Still good, as long as the process now exits.')
      bot.destroy()
      )


      Everything works except actually kicking the person. The message sends nut it doesn't kick people. For example, when I type in ?kick @BobNuggets#4576 inactive, it says
      @rishabhase has kicked @BobNuggets
      Reason: inactive


      But it doesn't actually kick the user, which is weird, can you help me?







      javascript node.js discord discord.js






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 21 at 22:00









      Rishi Ryan

      414




      414






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Change



          msg.guild.member(kickUser).kick();


          to



          kickUser.kick();


          also, make sure the bot is elevated in hierarchy






          share|improve this answer



























            up vote
            0
            down vote













            Use kickUser.kick();



            I recommend using a command handler to neaten up your code. You don't want all your commands in one .js file.






            share|improve this answer








            New contributor




            MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51460457%2fwhy-doesnt-kicking-people-work-using-discord-js%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote













              Change



              msg.guild.member(kickUser).kick();


              to



              kickUser.kick();


              also, make sure the bot is elevated in hierarchy






              share|improve this answer
























                up vote
                0
                down vote













                Change



                msg.guild.member(kickUser).kick();


                to



                kickUser.kick();


                also, make sure the bot is elevated in hierarchy






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Change



                  msg.guild.member(kickUser).kick();


                  to



                  kickUser.kick();


                  also, make sure the bot is elevated in hierarchy






                  share|improve this answer












                  Change



                  msg.guild.member(kickUser).kick();


                  to



                  kickUser.kick();


                  also, make sure the bot is elevated in hierarchy







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 22 at 3:56









                  Saddy

                  4239




                  4239






















                      up vote
                      0
                      down vote













                      Use kickUser.kick();



                      I recommend using a command handler to neaten up your code. You don't want all your commands in one .js file.






                      share|improve this answer








                      New contributor




                      MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.





















                        up vote
                        0
                        down vote













                        Use kickUser.kick();



                        I recommend using a command handler to neaten up your code. You don't want all your commands in one .js file.






                        share|improve this answer








                        New contributor




                        MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.



















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Use kickUser.kick();



                          I recommend using a command handler to neaten up your code. You don't want all your commands in one .js file.






                          share|improve this answer








                          New contributor




                          MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          Use kickUser.kick();



                          I recommend using a command handler to neaten up your code. You don't want all your commands in one .js file.







                          share|improve this answer








                          New contributor




                          MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer






                          New contributor




                          MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered Nov 10 at 14:05









                          MyNameIsVati

                          84




                          84




                          New contributor




                          MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          MyNameIsVati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51460457%2fwhy-doesnt-kicking-people-work-using-discord-js%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              這個網誌中的熱門文章

                              How to read a connectionString WITH PROVIDER in .NET Core?

                              Node.js Script on GitHub Pages or Amazon S3

                              Museum of Modern and Contemporary Art of Trento and Rovereto