title: How can I get access to Discord API guild's channel actions?
body: <p>I am new to Javascript. Now I am working on a Chrome Extension.
  I need to realize ability to create a Discord guild channel by clicking link in the Chrome Extension.</p>
  
  <p>I am successfully signing in via Discord in the Chrome Extension and getting access token. After this I'm trying to create channel, but always getting 401 Unauthorized. </p>
  
  <p>But where I do GET request to show user guilds (/users/@me/guilds) it works, but when trying to GET channels (/users/@me/channels) I receiving only 401 unauthorized..</p>
  
  <p>Could anybody explain what I'm doing wrong?
  Thank you in advance)</p>
  
  <p>Here is my code:
  (scope from first request: guilds.join, identify, guilds, email, connections, messages.read, bot, rpc, rpc.api)</p>
  
  <pre><code>$("#discord_sign_in").click(function () {
      chrome.identity.launchWebAuthFlow(
          {'url': 'https://discordapp.com/api/oauth2/authorize?client_id=*hidden*&amp;redirect_uri=https%3A%2F%2Fgnbkehnofikpgioaajgmejnkihdkpiap.chromiumapp.org%2Fsettings%2Findex.html&amp;response_type=code&amp;scope=guilds.join%20identify%20guilds%20email%20connections%20messages.read%20bot%20rpc%20rpc.api',
          'interactive': true},
          function(redirect_url) { 
              console.log('Authorization success'); 
              console.log(redirect_url);
              // var redirect_url = redirect.replace("#", "?");
              var url = new URL(redirect_url);
              var code = url.searchParams.get("code");
              console.log(code);
  
              localStorage.setItem('discord_code', code);
  
              console.log('get new code: ' + localStorage.getItem('discord_code'));
  
          });
      });
  
  
  $("#discord_sign_in_bot").click(function() {
      $.ajax( {
          url: 'https://discordapp.com/api/v6/oauth2/token',
          type: 'POST',
          data: { grant_type: 'authorization_code',
                  scope: 'bot',
                  client_id: 'localStorage.getItem('client_id')',
                  client_secret: 'localStorage.getItem('client_secret')',
                  code: localStorage.getItem('discord_code'),
                  permissions: 8,
                  redirect_uri: 'https://gnbkehnofikpgioaajgmejnkihdkpiap.chromiumapp.org/settings/index.html' },
          success: function( response ) {
              console.log("Successfully authorized bot (Discord).")
              console.log(response);
              console.log("access_token: " + response['access_token']);
              localStorage.setItem('discord_token', response['access_token']);
          },
          error: function () {
              console.log("Failed to bot authorization (Discord).")
          }
      } );
  });
  
  $("#discord_create_channel").click(function() {
      $.ajax( {
          url: 'https://discordapp.com/api/v6/guilds/594100687508340776/channels/',
          type: 'POST',
          data: { name: 'Test-channel-5' },
          beforeSend : function( xhr ) {
              xhr.setRequestHeader( "Authorization", "Bot " + localStorage.getItem('discord_token'));
          },
          success: function( response ) {
              console.log("Successfully created guild channel (Discord).")
          },
          error: function (response) {
              console.log(response);
              console.log("Failed to create guild channel (Discord).")
          }
      } );
  });
  </code></pre>