diff --git a/assets/overlays.json b/assets/overlays.json index a9e59b7..e39626c 100644 --- a/assets/overlays.json +++ b/assets/overlays.json @@ -16,5 +16,6 @@ "thuglife", "balance", "brilliance", - "bravery" + "bravery", + "wasted" ] \ No newline at end of file diff --git a/docs/guide/examples.md b/docs/guide/examples.md index e58142b..7783886 100644 --- a/docs/guide/examples.md +++ b/docs/guide/examples.md @@ -15,7 +15,7 @@ const WeebyAPI = require('weeby-js'); const weeby = new WeebyAPI('YOUR_TOKEN'); const image = await weeby.generators.oneImage({ type: '3000years', image: 'https://i.imgur.com/qgKvcQv.png' }); -message.channel.send({files: [{ attachment: image }]}); // -> Image Buffer +return image; // -> Image Buffer ``` ### Custom: @@ -24,8 +24,6 @@ const WeebyAPI = require('weeby-js'); const weeby = new WeebyAPI('YOUR_TOKEN'); const image = await weeby.custom.greeting({ icon: 'https://i.imgur.com/qgKvcQv.png', background: 'https://i.imgur.com/ENbvdWD.png', greet: 'Welcome', name: 'Nate', message: 'Hello and Welcome!', greetHex: 'E881D1', messageHex: '76d6ff', circleHex: '6b6d75', nameHex: 'e889e0', font: 'riffic' }); -message.channel.send({files: [{ attachment: image }]}); // -> Image Buffer -``` -More Examples can be found in `/test/bot-v12.js`. -> NOTE: Bot Example is outdated and is strongly discouraged from production use. \ No newline at end of file +return image; // -> Image Buffer +``` \ No newline at end of file diff --git a/docs/guide/setup.md b/docs/guide/setup.md index 373e942..af1232e 100644 --- a/docs/guide/setup.md +++ b/docs/guide/setup.md @@ -28,7 +28,7 @@ WEEBY_TOKEN= ```js const WeebyAPI = require('weeby-js'); -require('dotenv').config();) +require('dotenv').config(); const weeby = new WeebyAPI(process.env.WEEBY_TOKEN); ``` diff --git a/package-lock.json b/package-lock.json index 331feb5..35569d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "weeby-js", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index a723174..4a7e10a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "weeby-js", - "version": "2.0.0", + "version": "2.0.1", "description": "JavaScript Wrapper for Weeby API", "main": "src/index.js", "scripts": { @@ -27,12 +27,12 @@ "homepage": "https://js.weebyapi.xyz/", "devDependencies": { "@discordjs/docgen": "^0.11.0", - "common-tags": "^1.8.0", + "common-tags": "^1.8.2", "dotenv": "^16.0.0", - "eslint": "^8.9.0", + "eslint": "^8.11.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^6.0.0", - "typescript": "^4.5.5" + "typescript": "^4.6.2" }, "dependencies": { "chalk": "^4.1.2", diff --git a/src/lib/utility.js b/src/lib/utility.js index 3d2b686..58bd0aa 100644 --- a/src/lib/utility.js +++ b/src/lib/utility.js @@ -47,6 +47,30 @@ class Utility { } } + /** + * Checks if a user has voted for a server on Top.gg + * @param {TopGGServerVoteCheckerOptions} options - The options you want to use. + * @returns {Promise} + */ + async topGGServerVoteChecker({ serverID, userID }) { + if (typeof serverID !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The Server ID parameter is not a string.')}`); + if (!serverID) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('Server ID parameter is missing. You will need to provide a valid Bot ID.')}`); + if (typeof userID !== 'string') throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('The User ID parameter is not a string.')}`); + if (!userID) throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow('User ID parameter is missing. You will need to provide a valid User ID.')}`); + + try { + const { body } = await get(`${this.baseURL}/webhook/topgg/server/votecheck`) + .query({ serverid: serverID, userid: userID }) + .set('Authorization', `Bearer ${this.token}`) + .set('User-Agent', `Weeby-JS by NTM Development » v${version}`); + + return body; + } + catch (e) { + throw new Error(`${chalk.magenta('Weeby-JS')} ${chalk.gray('»')} ${chalk.yellow(`Could not find that User's vote information for Server ID: ${serverID}. Make sure the User ID and Server ID is correct, or the user should vote first.`)}`); + } + } + /** * Converts the provided currency to a different currency. * @param {CurrencyConverterOptions} options - The options you want to use. @@ -132,6 +156,12 @@ module.exports = Utility; * @property {string} userID - The ID of the user you want to check. */ +/** + * @typedef {Object} TopGGServerVoteCheckerOptions - The options for the TopGGServerVoteChecker. + * @property {string} serverID - The ID of the server you want to check. + * @property {string} userID - The ID of the user you want to check. + */ + /** * @typedef {Object} TopGGVoteCheckerResponse - The response from the Top.gg Vote Checker method. * @property {string} userID - The ID of the user. @@ -143,6 +173,17 @@ module.exports = Utility; * @property {boolean} isWeekend - Whether the user voted on a weekend or not. */ +/** + * @typedef {Object} TopGGServerVoteCheckerResponse - The response from the Top.gg Server Vote Checker method. + * @property {string} userID - The ID of the user. + * @property {string} serverID - The ID of the server. + * @property {number} dateVoted - The date the user voted (Unix Timestamp) + * @property {number} currentVoteExpiry - The current expiry of the vote (12 Hours - Unix Timestamp) + * @property {number} timesVoted - The amount of times the user has voted lifetime for the bot. + * @property {boolean} hasVoted - Whether the user has voted or not. + * @property {boolean} isWeekend - Whether the user voted on a weekend or not. + */ + /** * @typedef {Object} TranslateOptions - The options for the Translate method. * @property {string} from - A valid ISO language code. Refer to this: http://www.lingoes.net/en/translator/langcode.htm diff --git a/typings/lib/utility.d.ts b/typings/lib/utility.d.ts index cfe70ef..b43261f 100644 --- a/typings/lib/utility.d.ts +++ b/typings/lib/utility.d.ts @@ -22,6 +22,17 @@ declare class Utility { * @returns {Promise} */ topGGVoteChecker({ botID, userID }: TopGGVoteCheckerOptions): Promise; + /** + * Converts the provided currency to a different currency. + * @param {CurrencyConverterOptions} options - The options you want to use. + * @returns {Promise} + */ + /** + * Checks if a user has voted for a server on Top.gg + * @param {TopGGServerVoteCheckerOptions} options - The options you want to use. + * @returns {Promise} + */ + topGGServerVoteChecker({ serverID, userID }: TopGGServerVoteCheckerOptions): Promise; /** * Converts the provided currency to a different currency. * @param {CurrencyConverterOptions} options - The options you want to use. @@ -42,7 +53,7 @@ declare class Utility { weather({ location, degreeType }?: WeatherOptions): Promise; } declare namespace Utility { - export { TopGGVoteCheckerOptions, TopGGVoteCheckerResponse, TranslateOptions, TranslateResponse, CurrencyConverterOptions, CurrencyConverterResponse, WeatherOptions, WeatherResponse }; + export { TopGGVoteCheckerOptions, TopGGVoteCheckerResponse, TopGGServerVoteCheckerOptions, TopGGServerVoteCheckerResponse, TranslateOptions, TranslateResponse, CurrencyConverterOptions, CurrencyConverterResponse, WeatherOptions, WeatherResponse }; } /** * - The options for the TopGGVoteChecker. @@ -57,6 +68,19 @@ type TopGGVoteCheckerOptions = { */ userID: string; }; +/** + * - The options for the TopGGServerVoteChecker. + */ + type TopGGServerVoteCheckerOptions = { + /** + * - The ID of the server you want to check. + */ + serverID: string; + /** + * - The ID of the user you want to check. + */ + userID: string; +}; /** * - The response from the Top.gg Vote Checker method. */ @@ -90,6 +114,39 @@ type TopGGVoteCheckerResponse = { */ isWeekend: boolean; }; +/** + * - The response from the Top.gg Vote Checker method. + */ + type TopGGServerVoteCheckerResponse = { + /** + * - The ID of the user. + */ + userID: string; + /** + * - The ID of the server. + */ + serverID: string; + /** + * - The date the user voted (Unix Timestamp) + */ + dateVoted: number; + /** + * - The current expiry of the vote (12 Hours - Unix Timestamp) + */ + currentVoteExpiry: number; + /** + * - The amount of times the user has voted lifetime for the bot. + */ + timesVoted: number; + /** + * - Whether the user has voted or not. + */ + hasVoted: boolean; + /** + * - Whether the user voted on a weekend or not. + */ + isWeekend: boolean; +}; /** * - The options for the Currency Converter. */