upload

Methods

(async, inner) upload(subdomains, tokens, cookies, options) → {Promise.<uploadResponseObject>}

Upload multiple emoji described by an existing list on disk, either as a json emoji admin list or emojipacks-like yaml.

Parameters:
Name Type Description
subdomains string | Array.<string>

a single or list of subdomains from which to download emoji. Must match respectively to tokens and cookies.

tokens string | Array.<string>

a single or list of tokens with which to authenticate. Must match respectively to subdomains and cookies.

cookies string | Array.<string>

a single or list of cookies used to authenticate access to the given subdomain. Must match respectively to subdomains and tokens.

options object

contains singleton or arrays of emoji descriptors.

Properties
Name Type Attributes Description
src string | Array.<string>

source emoji list files for the emoji to be added. Can either be in jsonEmojiListFormat or yamlEmojiListFormat

avoidCollisions boolean <optional>

if true, emoji being added will be renamed to not collide with existing emoji. See lib/util/helpers.avoidCollisions for logic and details // TODO: fix this link, maybe link to tests which has better examples

prefix string <optional>

string to prefix all emoji being uploaded

bustCache boolean <optional>

if true, ignore any adminList younger than 24 hours and repull slack instance's existing emoji. Can be useful for making options.avoidCollisions more accurate

output boolean <optional>

if false, no files will be written during execution. Prevents saving of adminList for future use, as well as the writing of log files

verbose boolean <optional>

if true, all messages will be written to stdout in addition to combined log file.

Source:
Example
var uploadOptions = {
  src: './emoji-list.json', // upload all the emoji in this json array of objects
  avoidCollisions: true, // append '-1' or similar if we try to upload a dupe
  prefix: 'new-' // prepend every emoji in src with "new-", e.g. "emoji" becomes "new-emoji"
};
var uploadResults = await emojme.upload('mySubdomain', 'myToken', 'myCookie', uploadOptions);
console.log(uploadResults);
// {
//   mySubdomain: {
//     collisions: [
//       { name: an-emoji-that-already-exists-in-mySubdomain ... }
//     ],
//     emojiList: [
//       { name: emoji-from-emoji-list-json ... },
//       { name: emoji-from-emoji-list-json ... },
//       ...
//     ]
//   }
// }

Type Definitions

jsonEmojiListFormat :Array

The required format of a json file that can be used as the options.src for upload

To see an example, use download, then look at buidl/*.adminList.json

Properties:
Name Type Description
emojiList Array
Properties
Name Type Description
emojiObject object
Properties
Name Type Description
name string

the name of the emoji

is_alias 1 | 0

whether or not the emoji is an alias. If 1, alias_for is require and url is ignored. If 0 vice versa

alias_for string

the name of the emoji this emoji is apeing

url string

the remote url or local path of the emoji

user_display_name string

the name of the emoji creator

Source:
Example
[
  {
     "name": "a_giving_lovely_generous_individual",
     "is_alias": 1,
     "alias_for": "caleb"
  },
  {
    "name": "gooddoggy",
    "is_alias": 0,
    "alias_for": null,
    "url": "https://emoji.slack-edge.com/T3T9KQULR/gooddoggy/849f53cf1de25f97.png"
  }
]

syncResponseObject :object

The upload response object, like other response objects, is organized by input subdomain.

Properties:
Name Type Description
subdomain object

each subdomain passed in to add will appear as a key in the response

Properties
Name Type Description
emojiList Array.<emojiList>

the list of emoji added to subdomain, with each element an emoji pulled from either srcSubdomain or subdomains less the subdomain in question.

collisions Array.<emojiList>

if options.avoidCollisions is false, emoji that cannot be uploaded due to existing conflicting emoji names will exist here

Source:

yamlEmojiListFormat :object

The required format of a yaml file that can be used as the options.src for upload

Properties:
Name Type Description
topLevelYaml object

all keys execpt for emojis are ignored

emojis Array

the array of emoji objects

Properties
Name Type Description
emojiObject object
Properties
Name Type Description
name string

the name of the emoji

src string

alias for name

is_alias 1 | 0

whether or not the emoji is an alias. If 1, alias_for is require and url is ignored. If 0 vice versa

alias_for string

the name of the emoji this emoji is apeing

url string

the remote url or local path of the emoji

user_display_name string

the name of the emoji creator

Source:
Example
title: animals
 emojis:
   - name: llama
     src: http://i.imgur.com/6bKXKUP.gif
   - name: alpaca
     src: http://i.imgur.com/c6QxTbM.gif