Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ZackStone/1c7c2f7ac98520c9c84d536880f96770 to your computer and use it in GitHub Desktop.

Select an option

Save ZackStone/1c7c2f7ac98520c9c84d536880f96770 to your computer and use it in GitHub Desktop.

Revisions

  1. Yitzhak Andrade created this gist Apr 14, 2017.
    48 changes: 48 additions & 0 deletions slack-invite-all-members-to-a-channel.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    /*
    https://webapps.stackexchange.com/questions/100820/how-do-i-invite-all-team-members-to-a-new-slack-channel#answer-104062
    Instructions: Just browse to the appropriate channel and paste
    this script (below) into your Chrome/Firefox dev console and hit enter.
    Then wait for the script to run until it completes.
    It might take time as there is a limit to how many users may be invited at once.
    The script will loop until all team members are invited.
    */
    var foundAny=false;
    function selectAllByLetter(remainingLetters) {
    console.log(remainingLetters)
    var letter = remainingLetters.pop();
    $("#channel_invite_filter").val(letter).trigger("input");
    setTimeout(function() {
    $(".channel_invite_member:not(hidden)").each(function(i, obj) {
    foundAny=true;
    this.click();
    });
    if (remainingLetters.length) {
    selectAllByLetter(remainingLetters);
    } else {
    setTimeout(function() {
    console.log("Inviting them all!")
    $('.invite_go').click()
    },400)
    }
    },300);
    }

    function inviteAllUsers() {
    foundAny=false;
    setTimeout(function () {
    setTimeout(function() {
    $('#channel_actions_toggle').click();
    },100)
    setTimeout(function() {
    $('#channel_invite_item').click();
    },200)
    //Enter each letter to trigger searches
    var remainingLetters = ["a","b","c","d","e","f","g","h","i","j","v","k","l","m","n","o","p","q","r","s","t","u","v","z"];
    selectAllByLetter(remainingLetters);
    if (foundAny) {
    inviteAllUsers();
    }
    }, 4000);
    }

    inviteAllUsers();