Source: api.js

  1. const fetch = require('node-fetch');
  2. const EventEmitter = require('events');
  3. const base = 'https://api.cool-img-api.ml/';
  4. const { getContent } = require('./function');
  5. class API extends EventEmitter {
  6. /**
  7. * @param {string} text Text to apprear
  8. * @returns {Buffer} The Processed image Buffer
  9. */
  10. async achievement(text) {
  11. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  12. const url = base + `achievement?text=${encodeURIComponent(text)}`;
  13. return await getContent(url);
  14. }
  15. /**
  16. * @param {string} text Text to apprear
  17. * @param {string} earth Text to apprear
  18. * @param {string} image The Image URL
  19. * @returns {Buffer} The Processed image Buffer
  20. */
  21. async alwayshasbeen(text, earth, image) {
  22. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  23. if (!earth) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  24. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  25. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  26. const url = base + `alwayshasbeen?text=${encodeURIComponent(text)}&earth=${encodeURIComponent(earth)}&image=${encodeURIComponent(image)}`;
  27. return await getContent(url);
  28. }
  29. /**
  30. * @param {string} image The Image URL
  31. * @returns {Buffer} The Processed image Buffer
  32. */
  33. async amiajoke(image) {
  34. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  35. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  36. const url = base + `amiajoke?image=${encodeURIComponent(image)}`;
  37. return await getContent(url);
  38. }
  39. /**
  40. * @param {string} image The Image URL
  41. * @returns {Buffer} The Processed image Buffer
  42. */
  43. async bad(image) {
  44. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  45. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  46. const url = base + `bad?image=${encodeURIComponent(image)}`;
  47. return await getContent(url);
  48. }
  49. /**
  50. * @param {string} image The Image URL
  51. * @returns {Buffer} The Processed image Buffer
  52. */
  53. async beautiful(image) {
  54. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  55. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  56. const url = base + `beautiful?image=${encodeURIComponent(image)}`;
  57. return await getContent(url);
  58. }
  59. /**
  60. * @param {string} image The Image URL
  61. * @param {string} image2 The Image URL
  62. * @returns {Buffer} The Processed image Buffer
  63. */
  64. async bed(image, image2) {
  65. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  66. if (!image2) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  67. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  68. const url = base + `bed?image=${encodeURIComponent(image)}&image2=${encodeURIComponent(image2)}`;
  69. return await getContent(url);
  70. }
  71. /**
  72. * @returns {Buffer} The Processed image Buffer
  73. */
  74. async birb() {
  75. const url = base + 'birb';
  76. return await getContent(url);
  77. }
  78. /**
  79. * @param {string} image The Image URL
  80. * @returns {Buffer} The Processed image Buffer
  81. */
  82. async blur(image) {
  83. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  84. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  85. const url = base + `blur?image=${encodeURIComponent(image)}`;
  86. return await getContent(url);
  87. }
  88. /**
  89. * @param {string} text Text to apprear
  90. * @returns {Buffer} The Processed image Buffer
  91. */
  92. async calling(text) {
  93. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  94. const url = base + `calling?text=${encodeURIComponent(text)}`;
  95. return await getContent(url);
  96. }
  97. /**
  98. * @param {string} text Text to apprear
  99. * @returns {Buffer} The Processed image Buffer
  100. */
  101. async captcha(text) {
  102. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  103. const url = base + `captcha?text=${encodeURIComponent(text)}`;
  104. return await getContent(url);
  105. }
  106. /**
  107. * @returns {Buffer} The Processed image Buffer
  108. */
  109. async cats() {
  110. const url = base + 'cats';
  111. return await getContent(url);
  112. }
  113. /**
  114. * @param {string} text Text to apprear
  115. * @returns {Buffer} The Processed image Buffer
  116. */
  117. async challenge(text) {
  118. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  119. const url = base + `challenge?text=${encodeURIComponent(text)}`;
  120. return await getContent(url);
  121. }
  122. /**
  123. * @param {string} text Text to apprear
  124. * @returns {Buffer} The Processed image Buffer
  125. */
  126. async changemymind(text) {
  127. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  128. const url = base + `changemymind?text=${encodeURIComponent(text)}`;
  129. return await getContent(url);
  130. }
  131. /**
  132. * @param {string} text Text to apprear
  133. * @returns {Buffer} The Processed image Buffer
  134. */
  135. async clyde(text) {
  136. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  137. const url = base + `clyde?text=${encodeURIComponent(text)}`;
  138. return await getContent(url);
  139. }
  140. /**
  141. * @param {string} image The Image URL
  142. * @returns {Buffer} The Processed image Buffer
  143. */
  144. async communist(image) {
  145. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  146. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  147. const url = base + `communist?image=${encodeURIComponent(image)}`;
  148. return await getContent(url);
  149. }
  150. /**
  151. * @param {string} text Text to apprear
  152. * @param {string} text2 Text to apprear
  153. * @returns {Buffer} The Processed image Buffer
  154. */
  155. async didyoumean(text, text2) {
  156. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  157. if (!text2) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  158. const url = base + `didyoumean?top=${encodeURIComponent(text)}&bottom=${encodeURIComponent(text2)}`;
  159. return await getContent(url);
  160. }
  161. /**
  162. * @param {string} text Text to apprear
  163. * @param {string} color Color of the username
  164. * @param {string} username Username to appear
  165. * @param {string} image The Image URL
  166. * @returns {Buffer} The Processed image Buffer
  167. */
  168. async discord_message(text, color, username, image) {
  169. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  170. if (!color) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  171. if (!username) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  172. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  173. const url = base + `discord-message?message=${encodeURIComponent(text)}&color=${encodeURIComponent(color)}&username=${encodeURIComponent(username)}&avatar=${encodeURIComponent(image)}`;
  174. console.log(url);
  175. return await getContent(url);
  176. }
  177. /**
  178. * @param {string} text Text to apprear
  179. * @param {string} text2 Text to apprear
  180. * @returns {Buffer} The Processed image Buffer
  181. */
  182. async dissapointed(text, text2) {
  183. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  184. if (!text2) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  185. const url = base + `dissapointed?top=${encodeURIComponent(text)}&bottom=${encodeURIComponent(text2)}`;
  186. return await getContent(url);
  187. }
  188. /**
  189. * @returns {Buffer} The Processed image Buffer
  190. */
  191. async dogs() {
  192. const url = base + 'dogs';
  193. return await getContent(url);
  194. }
  195. /**
  196. * @param {string} text Text to apprear
  197. * @param {string} text2 Text to apprear
  198. * @returns {Buffer} The Processed image Buffer
  199. */
  200. async drake(text, text2) {
  201. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  202. if (!text2) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  203. const url = base + `drake?top=${encodeURIComponent(text)}&bottom=${encodeURIComponent(text2)}`;
  204. return await getContent(url);
  205. }
  206. /**
  207. * @param {string} image The Image URL
  208. * @returns {Buffer} The Processed image Buffer
  209. */
  210. async facepalm(image) {
  211. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  212. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  213. const url = base + `facepalm?image=${encodeURIComponent(image)}`;
  214. return await getContent(url);
  215. }
  216. /**
  217. * @param {string} text Text to apprear
  218. * @returns {Buffer} The Processed image Buffer
  219. */
  220. async facts(text) {
  221. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  222. const url = base + `facts?text=${encodeURIComponent(text)}`;
  223. return await getContent(url);
  224. }
  225. /**
  226. * @param {string} image The Image URL
  227. * @returns {Buffer} The Processed image Buffer
  228. */
  229. async gay(image) {
  230. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  231. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  232. const url = base + `gay?image=${encodeURIComponent(image)}`;
  233. return await getContent(url);
  234. }
  235. /**
  236. * @param {string} image The Image URL
  237. * @returns {Buffer} The Processed image Buffer
  238. */
  239. async gun(image) {
  240. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  241. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  242. const url = base + `gun?image=${encodeURIComponent(image)}`;
  243. return await getContent(url);
  244. }
  245. /**
  246. * @param {string} image The Image URL
  247. * @returns {Buffer} The Processed image Buffer
  248. */
  249. async hitler(image) {
  250. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  251. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  252. const url = base + `hitler?image=${encodeURIComponent(image)}`;
  253. return await getContent(url);
  254. }
  255. /**
  256. * @param {string} image The Image URL
  257. * @returns {Buffer} The Processed image Buffer
  258. */
  259. async invert(image) {
  260. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  261. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  262. const url = base + `invert?image=${encodeURIComponent(image)}`;
  263. return await getContent(url);
  264. }
  265. /**
  266. * @param {string} image The Image URL
  267. * @returns {Buffer} The Processed image Buffer
  268. */
  269. async jail(image) {
  270. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  271. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  272. const url = base + `jail?image=${encodeURIComponent(image)}`;
  273. return await getContent(url);
  274. }
  275. /**
  276. * @param {string} image The Image URL
  277. * @returns {Buffer} The Processed image Buffer
  278. */
  279. async jokeoverhead(image) {
  280. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  281. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  282. const url = base + `jokeoverhead?image=${encodeURIComponent(image)}`;
  283. return await getContent(url);
  284. }
  285. /**
  286. * @returns {Buffer} The Processed image Buffer
  287. */
  288. async meme() {
  289. const url = base + 'meme';
  290. return await getContent(url);
  291. }
  292. /**
  293. * @param {string} text Text to apprear
  294. * @param {string} author Author to apprear
  295. * @param {string} image The Image URL
  296. * @returns {Buffer} The Processed image Buffer
  297. */
  298. async play_store(text, author, image) {
  299. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  300. if (!author) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  301. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  302. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  303. const url = base + `play-store?image=${encodeURIComponent(image)}&text=${encodeURIComponent(text)}&author=${encodeURIComponent(author)}`;
  304. return await getContent(url);
  305. }
  306. /**
  307. * @param {string} text Text to apprear
  308. * @returns {Buffer} The Processed image Buffer
  309. */
  310. async presentation(text) {
  311. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  312. const url = base + `presentation?text=${encodeURIComponent(text)}`;
  313. return await getContent(url);
  314. }
  315. /**
  316. * @returns {Object} The Processed image Buffer
  317. */
  318. async random_captcha() {
  319. const url = await fetch(base + 'random-captcha');
  320. const data = await url.json();
  321. return data;
  322. }
  323. /**
  324. * @param {string} image The Image URL
  325. * @returns {Buffer} The Processed image Buffer
  326. */
  327. async rip(image) {
  328. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  329. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  330. const url = base + `rip?image=${encodeURIComponent(image)}`;
  331. return await getContent(url);
  332. }
  333. /**
  334. * @param {string} image The Image URL
  335. * @returns {Buffer} The Processed image Buffer
  336. */
  337. async salty(image) {
  338. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  339. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  340. const url = base + `salty?image=${encodeURIComponent(image)}`;
  341. return await getContent(url);
  342. }
  343. /**
  344. * @param {string} text Text to apprear
  345. * @returns {Buffer} The Processed image Buffer
  346. */
  347. async scroll(text) {
  348. if (!text) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  349. const url = base + `scroll?text=${encodeURIComponent(text)}`;
  350. return await getContent(url);
  351. }
  352. /**
  353. * @param {string} image The Image URL
  354. * @returns {Buffer} The Processed image Buffer
  355. */
  356. async shame(image) {
  357. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  358. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  359. const url = base + `shame?image=${encodeURIComponent(image)}`;
  360. return await getContent(url);
  361. }
  362. /**
  363. * @param {string} image The Image URL
  364. * @param {string} image2 The Image URL
  365. * @returns {Buffer} The Processed image Buffer
  366. */
  367. async ship(image, image2) {
  368. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  369. if (!image2) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  370. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  371. const url = base + `ship?user=${encodeURIComponent(image)}&user2=${encodeURIComponent(image2)}`;
  372. return await getContent(url);
  373. }
  374. /**
  375. * @param {string} image The Image URL
  376. * @returns {Buffer} The Processed image Buffer
  377. */
  378. async shit(image) {
  379. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  380. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  381. const url = base + `shit?image=${encodeURIComponent(image)}`;
  382. return await getContent(url);
  383. }
  384. /**
  385. * @param {string} image The Image URL
  386. * @returns {Buffer} The Processed image Buffer
  387. */
  388. async simp(image) {
  389. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  390. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  391. const url = base + `simp?image=${encodeURIComponent(image)}`;
  392. return await getContent(url);
  393. }
  394. /**
  395. * @param {string} image The Image URL
  396. * @param {string} image2 The Image URL
  397. * @returns {Buffer} The Processed image Buffer
  398. */
  399. async spank(image, image2) {
  400. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  401. if (!image2) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  402. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  403. const url = base + `spank?user=${encodeURIComponent(image)}&user2=${encodeURIComponent(image2)}`;
  404. return await getContent(url);
  405. }
  406. /**
  407. * @param {string} image The Image URL
  408. * @returns {Buffer} The Processed image Buffer
  409. */
  410. async trash(image) {
  411. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  412. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  413. const url = base + `trash?image=${encodeURIComponent(image)}`;
  414. return await getContent(url);
  415. }
  416. /**
  417. * @param {string} image The Image URL
  418. * @returns {Buffer} The Processed image Buffer
  419. */
  420. async triggered(image) {
  421. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  422. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  423. const url = base + `triggered?image=${encodeURIComponent(image)}`;
  424. return await getContent(url);
  425. }
  426. /**
  427. * @param {string} image The Image URL
  428. * @returns {Buffer} The Processed image Buffer
  429. */
  430. async wanted(image) {
  431. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  432. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  433. const url = base + `wanted?image=${encodeURIComponent(image)}`;
  434. return await getContent(url);
  435. }
  436. /**
  437. * @param {string} image The Image URL
  438. * @returns {Buffer} The Processed image Buffer
  439. */
  440. async wasted(image) {
  441. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  442. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  443. const url = base + `wasted?image=${encodeURIComponent(image)}`;
  444. return await getContent(url);
  445. }
  446. /**
  447. * @param {string} location Text to apprear
  448. * @param {string} image The Image URL
  449. * @returns {Buffer} The Processed image Buffer
  450. */
  451. async weather_card(location, image) {
  452. if (!location) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  453. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  454. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  455. const url = base + `weather-card?location=${encodeURIComponent(location)}&background=${encodeURIComponent(image)}`;
  456. return await getContent(url);
  457. }
  458. /**
  459. * @param {string} image The Image URL
  460. * @returns {Buffer} The Processed image Buffer
  461. */
  462. async what(image) {
  463. if (!image) throw new Error('APIError: Inavlid parameters provided! Docs: https://cool-img-api.js.org');
  464. if (typeof image !== 'string') throw new Error('image URL should be passed as a STRING');
  465. const url = base + `what?image=${encodeURIComponent(image)}`;
  466. return await getContent(url);
  467. }
  468. }
  469. module.exports = API;