add

Methods

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

Add emoji described by parameters within options to the specified subdomain(s).

Note that options can accept both aliases and original emoji at the same time, but ordering can get complicated and honestly I'd skip it if I were you. For each emoji, make sure that every descriptor (src, name, aliasFor) has a value, using nulls for fields that are not relevant to the current emoji.

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

a single or list of subdomains to add emoji to. Must match respectively to tokens and cookies.

tokens string | Array.<string>

a single or list of tokens to add emoji to. 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> <optional>

source image files for the emoji to be added. If no corresponding options.name is given, the filename will be used

name string | Array.<string> <optional>

names of the emoji to be added, overriding filenames if given, and becoming the alias name if an options.aliasFor is given

aliasFor string | Array.<string> <optional>

names of emoji to be aliased to options.name

allowCollisions boolean <optional>

if true, emoji being uploaded will not be checked against existing emoji. This will take less time up front but may cause more errors.

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

Source:
Example
var addOptions = {
  src: ['./emoji1.jpg', 'http://example.com/emoji2.png'], // upload these two images
  name: ['myLocalEmoji', 'myOnlineEmoji'], // call them these two names
  bustCache: false, // don't bother redownloading existing emoji
  avoidCollisions: true, // if there are similarly named emoji, change my new emoji names
  output: false // don't write any files
};
var subdomains = ['mySubdomain1', 'mySubdomain2'] // can add one or multiple
var tokens = ['myToken1', 'myToken2'] // can add one or multiple
var cookies = ['myCookie1', 'myCookie2'] // can add one or multiple
var addResults = await emojme.add(subdomains, tokens, cookies, addOptions);
console.log(userStatsResults);
// {
//   mySubomain1: {
//     collisions: [], // only defined if avoidCollisons = false
//     emojiList: [
//       { name: 'myLocalEmoji', ... },
//       { name: 'myOnlineEmoji', ... },
//     ]
//   },
//   mySubomain2: {
//     collisions: [], // only defined if avoidCollisons = false
//     emojiList: [
//       { name: 'myLocalEmoji', ... },
//       { name: 'myOnlineEmoji', ... },
//     ]
//   }
// }

Type Definitions

addResponseObject :object

The add 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 reflecting the parameters passed in to add

collisions Array.<emojiList>

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

Source: