0.1.2 • Published 2 months ago

@snazzah/emoji-sync v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@snazzah/emoji-sync

A utility package to sync emojis with your Discord application

NPM version NPM downloads JSR discord chat

Installation

pnpm i @snazzah/emoji-sync

Usage

import { EmojiManager } from '@snazzah/emoji-sync';

const manager = new EmojiManager({ token: '...' });

// Note: you can add an emoji key type in the emoji manager so methods are typed properly
// new EmojiManager<'success' | 'failure' | 'snazzah'>({ token: '...' })

// Load emojis from a folder to sync with later
await manager.loadFromFolder('./emojis', { recursive: true });

// ...or manually specify emojis as an object of keys
manager.load({
  // file path (detects type from extension)
  success: './emojis/success.png',
  // data image uri
  failure: 'data:image/png;base64,...',
  // http(s) urls (detect from Content-Type or extension)
  snazzah: 'https://cdn.snaz.in/avy/current.min.png'
});

// ...and sync it!
await manager.sync();

// Now that emojis are populated in the manager, you can start using them:

// Get a partial emoji for use in buttons and selects
manager.getPartial('success'); // { id: '123...', name: 'success', animated: false }
// Get the entire emoji object
manager.get('success'); // { id: '123...', ... }
// Get the formatted markdown of an emoji
manager.getMarkdown('success'); // "<:success:123>"

Updating an emoji

If you want to update an emoji, you should:

  • Rename the old emoji to something else: _old_success
  • Upload the new emoji under the same name
  • Reload old instances of your application so that all managers use the new ID
  • Remove the old emoji once other manager are up to date
0.1.2

2 months ago

0.1.1

4 months ago

0.1.0

4 months ago