discord-emoji-convert
Advanced tools
Comparing version
109
index.js
@@ -0,86 +1,33 @@ | ||
let num_words = ['zero','one','two','three','four', | ||
'five','six','seven','eight','nine']; | ||
var finalWords = '' | ||
let symbolTable = { | ||
"!": ':exclamation:', | ||
"?": ':question:', | ||
"+": ":heavy_plus_sign:", | ||
"-": ":heavy_minus_sign:", | ||
"×": ":heavy_multiplication_x:", | ||
"*": ":asterisk:", | ||
"$": ":heavy_dollar_sign:", | ||
"/": ":heavy_division_sign:" | ||
}; | ||
function check (suffix) { | ||
var thing | ||
switch (suffix) { | ||
case ' ': | ||
thing = ' ' | ||
break | ||
case '!': | ||
thing = ' :exclamation:' | ||
break | ||
case '?': | ||
thing = ' :question:' | ||
break | ||
case '0': | ||
thing = ' :zero:' | ||
break | ||
case '1': | ||
thing = ' :one:' | ||
break | ||
case '2': | ||
thing = ' :two:' | ||
break | ||
case '3': | ||
thing = ' :three:' | ||
break | ||
case '4': | ||
thing = ' :four:' | ||
break | ||
case '5': | ||
thing = ' :five:' | ||
break | ||
case '6': | ||
thing = ' :six:' | ||
break | ||
case '7': | ||
thing = ' :seven:' | ||
break | ||
case '8': | ||
thing = ' :eight:' | ||
break | ||
case '9': | ||
thing = ' :nine:' | ||
break | ||
case '+': | ||
thing = ' :heavy_plus_sign:' | ||
break | ||
case '-': | ||
thing = ' :heavy_minus_sign:' | ||
break | ||
case '×': | ||
thing = ' :heavy_multiplication_x:' | ||
break | ||
case '*': | ||
thing = ' :asterisk:' | ||
break | ||
case '$': | ||
thing = ' :heavy_dollar_sign:' | ||
break | ||
case '/': | ||
thing = ' :heavy_division_sign:' | ||
break | ||
default: | ||
thing = suffix | ||
break | ||
} | ||
return thing | ||
} | ||
// This code may feel inefficient, bulky, and horrible all at the same time. That's ok, It serves its purpose. - Jacob Snarr | ||
exports.convert = function (phrase) { | ||
phrase = phrase.toLowerCase() | ||
var i | ||
var bigWords = '' | ||
for (i = 1; i < phrase.length + 1; i++) { | ||
if (phrase.substring(i - 1, i).match(/[a-z]/i)) { | ||
var character = ' :regional_indicator_' + phrase.substring(i - 1, i) + ':' | ||
bigWords = bigWords + character | ||
exports.convert = (input) => { | ||
input = input.toLowerCase(); | ||
let finalString = ''; | ||
for (let i = 0; i < input.length; i++) { | ||
let rawCharacter = input.substring(i, i+1); | ||
let emojiText = ''; | ||
if (rawCharacter.match(/[a-z]/i)) { | ||
emojiText = `:regional_indicator_${rawCharacter}:`; | ||
} else if (rawCharacter.match(/[0-9]/i)) { | ||
emojiText = `:${num_words[parseInt(rawCharacter)]}:`; | ||
} else { | ||
bigWords = bigWords + check(phrase.substring(i - 1, i)) | ||
let symbol = symbolTable[rawCharacter]; | ||
if (!symbol) continue; | ||
emojiText = symbol; | ||
} | ||
finalString += `${emojiText} `; | ||
} | ||
return bigWords.substring(1, bigWords.length) | ||
} | ||
return finalString.trimEnd() | ||
} |
{ | ||
"_from": "discord-emoji-convert", | ||
"_id": "discord-emoji-convert@1.3.1", | ||
"_inBundle": false, | ||
"_integrity": "sha512-B2NB9NeXyRIFEXfooxfdlb17L4MmkCagzd1uXRTVVVnSy6da+rQlFzrGSkoVObxYtC7xpU/MOvav36r5Xg9wTg==", | ||
"_location": "/discord-emoji-convert", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"type": "tag", | ||
"registry": true, | ||
"raw": "discord-emoji-convert", | ||
"name": "discord-emoji-convert", | ||
"escapedName": "discord-emoji-convert", | ||
"rawSpec": "", | ||
"saveSpec": null, | ||
"fetchSpec": "latest" | ||
"name": "discord-emoji-convert", | ||
"version": "2.0.0", | ||
"description": "A very simple text to emoji converter for Discord", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"_requiredBy": [ | ||
"#USER", | ||
"/" | ||
], | ||
"_resolved": "https://registry.npmjs.org/discord-emoji-convert/-/discord-emoji-convert-1.3.1.tgz", | ||
"_shasum": "72249c816d002a14f477eba6389541d1af82f7f2", | ||
"_spec": "discord-emoji-convert", | ||
"_where": "D:\\Owner\\Documents\\GitHub\\SnarrBot", | ||
"author": { | ||
"name": "JacobSnarr" | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Snarr/discord-emoji-convert" | ||
}, | ||
"bundleDependencies": false, | ||
"dependencies": {}, | ||
"deprecated": false, | ||
"description": "A very simple Text to Emoji converter for Discord", | ||
"keywords": [ | ||
"discord" | ||
"discord", | ||
"emoji", | ||
"convert" | ||
], | ||
"author": "Snarr", | ||
"license": "ISC", | ||
"main": "index.js", | ||
"name": "discord-emoji-convert", | ||
"scripts": {}, | ||
"version": "1.6.0" | ||
"bugs": { | ||
"url": "https://github.com/Snarr/discord-emoji-convert/issues" | ||
}, | ||
"homepage": "https://github.com/Snarr/discord-emoji-convert#readme" | ||
} |
@@ -1,23 +0,52 @@ | ||
[](https://nodei.co/npm/discord-emoji-convert/) | ||
<h1 align="center">Welcome to discord-emoji-convert 👋</h1> | ||
<p> | ||
<a href="https://www.npmjs.com/package/discord-emoji-convert" target="_blank"> | ||
<img alt="Version" src="https://img.shields.io/npm/v/discord-emoji-convert.svg"> | ||
</a> | ||
<a href="https://www.npmjs.com/package/discord-emoji-convert" target="_blank"> | ||
<img alt="npm" src="https://img.shields.io/npm/dt/discord-emoji-convert"> | ||
</a> | ||
<a href="https://github.com/Snarr/discord-emoji-convert/blob/master/LICENSE" target="_blank"> | ||
<img alt="License: ISC" src="https://img.shields.io/github/license/Snarr/discord-emoji-convert" /> | ||
</a> | ||
</p> | ||
[](https://standardjs.com)  [](http://discord.snarr.io/)  | ||
# Installation | ||
To install Discord Emoji Convert, simply use the following command: | ||
> A very simple text to emoji converter for Discord | ||
```npm install discord-emoji-convert``` | ||
### 🏠 [Homepage](https://github.com/Snarr/discord-emoji-convert#readme) | ||
Add this to your code as well: | ||
## Install | ||
```const emoji = require('discord-emoji-convert');``` | ||
```sh | ||
npm install discord-emoji-convert | ||
``` | ||
# Using Emoji Convert | ||
To convert any string to emojis, type ```emoji.convert("insert string here")``` and the function will return your converted Discord Emoji string. | ||
## Usage | ||
# Supported Characters | ||
```abcdefghijklmnopqrstuvwxyz1234567890+-x*/$!? ``` | ||
This includes uppercase characters since all characters are converted to lowercase in order for the Discord Emojis to work. "/" is converted to the Discord Division Emoji and spaces are simply just lengthened to be three spaces. | ||
```js | ||
const { convert } = require("discord-emoji-convert") | ||
console.log(convert("Hello World!")) | ||
``` | ||
# Example | ||
Inserting ```console.log(emoji.convert("SNARR"));``` into your code, this module will output the following string: | ||
## Author | ||
```:regional_indicator_s: :regional_indicator_n: :regional_indicator_a: :regional_indicator_r: :regional_indicator_r:``` | ||
👤 **Snarr** | ||
* LinkedIn: https://www.linkedin.com/in/Snarr/ | ||
* Github: [@Snarr](https://github.com/Snarr) | ||
## 🤝 Contributing | ||
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/Snarr/discord-emoji-convert/issues). | ||
## Show your support | ||
Give a ⭐️ if this project helped you! | ||
## 📝 License | ||
Copyright © 2021 [Snarr](https://github.com/Snarr).<br /> | ||
This project is [ISC](https://github.com/Snarr/discord-emoji-convert/blob/master/LICENSE) licensed. | ||
*** | ||
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_ |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
-100%52
116.67%0
-100%3127
-29.76%30
-63.41%