discord.js-akinator
Advanced tools
Comparing version 4.1.5 to 5.0.0
{ | ||
"name": "discord.js-akinator", | ||
"version": "4.1.5", | ||
"version": "5.0.0", | ||
"description": "A Discord.js v14 module that allows you to create an Akinator command for your discord bot in a matter of seconds.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -7,8 +7,17 @@ <h1 align="center"> | ||
[![NPM](https://nodei.co/npm/discord.js-akinator.png)](https://npmjs.com/package/discord.js-akinator) | ||
<div align="center"> | ||
[![Downloads](https://img.shields.io/npm/dt/discord.js-akinator?logo=npm&style=flat-square)](https://npmjs.com/package/discord.js-akinator) [![Discord Server](https://img.shields.io/discord/667479986214666272?logo=discord&logoColor=white&style=flat-square)](https://diamonddigital.dev/discord) | ||
![license](https://img.shields.io/npm/l/discord.js-akinator?style=flat-square) | ||
[![version](https://img.shields.io/npm/v/discord.js-akinator?style=flat-square)](https://npmjs.com/package/discord.js-akinator) | ||
[![gzipped size](https://img.shields.io/bundlejs/size/discord.js-akinator?style=flat-square)](https://npmjs.com/package/discord.js-akinator) | ||
[![downloads](https://img.shields.io/npm/dt/discord.js-akinator?style=flat-square)](https://npmjs.com/package/discord.js-akinator) | ||
![last commit](https://img.shields.io/github/last-commit/WillTDA/Discord.js-Akinator?style=flat-square) | ||
<a href="https://www.buymeacoffee.com/willtda" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a> | ||
[![discord](https://img.shields.io/discord/667479986214666272?logo=discord&logoColor=white&style=flat-square)](https://diamonddigital.dev/discord) | ||
[![buy me a coffee](https://img.shields.io/badge/-Buy%20Me%20a%20Coffee-ffdd00?logo=Buy%20Me%20A%20Coffee&logoColor=000000&style=flat-square)](https://www.buymeacoffee.com/willtda) | ||
</div> | ||
<br /> | ||
## Features | ||
@@ -28,7 +37,7 @@ | ||
## Installation & Compatibility List | ||
## Installation | ||
To install this package, simply run the following command in your terminal: | ||
`npm i discord.js-akinator --save` | ||
`npm i discord.js-akinator` | ||
@@ -61,3 +70,2 @@ **Please Note:** The latest release of this package is only compatible with Discord.js v14. | ||
const childMode = false; //Whether to use Akinator's Child Mode. Defaults to "false". | ||
const gameType = "character"; //The type of Akinator game to be played. ("animal", "character" or "object"). Defaults to "character". | ||
const useButtons = true; //Whether to use Discord's buttons instead of message input for answering questions. Defaults to "true". | ||
@@ -81,3 +89,2 @@ const embedColor = "#1F1E33"; //The color of the message embeds. Defaults to "Random". | ||
childMode: childMode, | ||
gameType: gameType, | ||
useButtons: useButtons, | ||
@@ -103,3 +110,2 @@ embedColor: embedColor, | ||
childMode: childMode, | ||
gameType: gameType, | ||
useButtons: useButtons, | ||
@@ -122,6 +128,8 @@ embedColor: embedColor, | ||
- 👾 Found a bug, or inaccurate translations? [Open an issue](https://github.com/WillTDA/Discord.js-Akinator/issues), or fork and [submit a pull request](https://github.com/WillTDA/Discord.js-Akinator/pulls) on our [GitHub repository](https://github.com/WillTDA/Discord.js-Akinator)! | ||
<hr> | ||
<center> | ||
<a href="https://diamonddigital.dev/"><strong>Created and maintained by</strong> | ||
<img align="center" style="width:25%;height:auto" src="https://diamonddigital.dev/img/png/ddd_logo_text_transparent.png" alt="Diamond Digital Development Logo"></a> | ||
</center> | ||
--- | ||
<a href="https://diamonddigital.dev/"> | ||
<strong>Created and maintained by</strong> | ||
<img align="center" alt="Diamond Digital Development Logo" src="https://diamonddigital.dev/img/png/ddd_logo_text_transparent.png" style="width:25%;height:auto" /> | ||
</a> |
@@ -25,3 +25,2 @@ const Discord = require("discord.js") | ||
* @prop {boolean} [options.childMode=false] Whether to use Akinator's Child Mode. Defaults to `false`. | ||
* @prop {"character" | "animal" | "object"} [options.gameType="character"] The type of Akinator game to be played. Defaults to `character`. | ||
* @prop {boolean} [options.useButtons=true] Whether to use Discord's buttons instead of message input for answering questions. Defaults to `true`. | ||
@@ -58,3 +57,2 @@ * @prop {Discord.ColorResolvable} [options.embedColor="Random"] The color of the message embeds. Defaults to `Random`. | ||
options.childMode = options.childMode !== undefined ? options.childMode : false; | ||
options.gameType = options.gameType || "character"; | ||
options.useButtons = options.useButtons !== undefined ? options.useButtons : true; | ||
@@ -69,3 +67,2 @@ options.embedColor = Discord.resolveColor(options.embedColor || "Random"); | ||
options.language = options.language.toLowerCase(); | ||
options.gameType = options.gameType.toLowerCase(); | ||
@@ -77,3 +74,2 @@ //error handling | ||
if (!fs.existsSync(`${__dirname}/translations/${options.language}.json`)) return console.log(`Discord.js Akinator Error: Language "${options.language}" cannot be found. Examples: "en", "fr", "es", etc.\nNeed help? Join our Discord server at 'https://discord.gg/P2g24jp'`); | ||
if (!["animal", "character", "object"].includes(options.gameType)) return console.log(`Discord.js Akinator Error: Game type "${options.gameType}" cannot be found. Choose from: "animal", "character" or "object".\nNeed help? Join our Discord server at 'https://discord.gg/P2g24jp'`); | ||
@@ -116,4 +112,3 @@ try { | ||
//starts the game | ||
let gameTypeRegion = options.gameType == "animal" ? "en_animals" : options.gameType == "character" ? "en" : "en_objects"; | ||
let aki = new Aki({ region: gameTypeRegion, childMode: options.childMode }); | ||
let aki = new Aki({ region: "en", childMode: options.childMode }); // set to en region, translation is handled later | ||
let akiData = await aki.start(); | ||
@@ -158,4 +153,4 @@ | ||
let guessEmbed = { | ||
title: `${await translate(`I'm ${Math.round(aki.progress)}% sure your ${options.gameType} is...`, options.language, options.translationCaching)}`, | ||
description: `**${aki.guess.name_proposition}**\n${await translate(aki.guess.description_proposition, options.language, options.translationCaching)}\n\n${options.gameType == "animal" ? translations.isThisYourAnimal : options.gameType == "character" ? translations.isThisYourCharacter : translations.isThisYourObject} ${!options.useButtons ? `**(Type Y/${translations.yes} or N/${translations.no})**` : ""}`, | ||
title: `${await translate(`I'm ${Math.round(aki.progress)}% sure your character is...`, options.language, options.translationCaching)}`, | ||
description: `**${aki.guess.name_proposition}**\n${await translate(aki.guess.description_proposition, options.language, options.translationCaching)}\n\n${translations.isThisYourCharacter} ${!options.useButtons ? `**(Type Y/${translations.yes} or N/${translations.no})**` : ""}`, | ||
color: options.embedColor, | ||
@@ -192,3 +187,3 @@ image: { url: aki.guess.photo }, | ||
fields: [ | ||
{ name: translations[options.gameType], value: `**${aki.guess.name_proposition}**`, inline: true }, | ||
{ name: "Character", value: `**${aki.guess.name_proposition}**`, inline: true }, | ||
//{ name: translations.ranking, value: `**#${aki.answers[0].ranking}**`, inline: true }, //NO LONGER SUPPORTED | ||
@@ -329,2 +324,2 @@ { name: translations.noOfQuestions, value: `**${aki.currentStep}**`, inline: true } | ||
} | ||
}; | ||
}; |
@@ -15,3 +15,3 @@ const fs = require("fs"); | ||
module.exports = async function translate(string, language, cachingOptions) { | ||
if (!string) return console.log("Discord.js Akinator Translator: No String Provided!") | ||
if (!string) return; | ||
if (!language) return console.log("Discord.js Akinator Translator: No Language Provided!") | ||
@@ -18,0 +18,0 @@ if (!cachingOptions) return console.log("Discord.js Akinator Translator: No Caching Options Provided!") |
130
190807
3649