๐——๐—”๐—ฅ๐—ฅ๐—˜๐—Ÿ๐—Ÿ ๐— ๐—จ๐—–๐—›๐—˜๐—ฅ๐—œ โšก commited on
Commit
2db97af
ยท
unverified ยท
1 Parent(s): 98e346a

Create search-npm.js

Browse files
Files changed (1) hide show
  1. plugins/search-npm.js +53 -0
plugins/search-npm.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const axios = require("axios");
2
+ const config = require("../config");
3
+ const {
4
+ cmd,
5
+ commands
6
+ } = require("../command");
7
+
8
+
9
+ const _0x50a4a6 = {
10
+ pattern: "npm",
11
+ desc: "Search for a package on npm.",
12
+ react: '๐Ÿ“ฆ',
13
+ use: ".npm < name >"
14
+ };
15
+ function _0x44eff2(_0x4311d2, _0x3babb0, _0x904d87, _0x18ffad, _0x1c70c8) {
16
+ return _0x479a(_0x3babb0 - 0x348, _0x18ffad);
17
+ }
18
+ _0x50a4a6.category = "convert";
19
+ _0x50a4a6.filename = __filename;
20
+ cmd(_0x50a4a6, async (_0x45c3e3, _0x534cf5, _0x3c9af3, {
21
+ from: _0x4a8b86,
22
+ args: _0xfde2e1,
23
+ reply: _0x5ddb6d
24
+ }) => {
25
+ if (!_0xfde2e1.length) {
26
+ return _0x5ddb6d("Please provide the name of the npm package you want to search for. Example: !npm express");
27
+ }
28
+ const _0x71d130 = _0xfde2e1.join(" ");
29
+ const _0x2b9e87 = "https://registry.npmjs.org/" + encodeURIComponent(_0x71d130);
30
+ try {
31
+ let _0x38bc8e = await fetch(_0x2b9e87);
32
+ if (!_0x38bc8e.ok) {
33
+ throw new Error("Package not found or an error occurred.");
34
+ }
35
+ let _0x27bf7a = await _0x38bc8e.json();
36
+ const _0x39dfb0 = _0x27bf7a["dist-tags"].latest;
37
+ const _0x4a0adb = _0x27bf7a.description || "No description available.";
38
+ const _0x484c23 = "https://www.npmjs.com/package/" + _0x71d130;
39
+ const _0x1f70c0 = _0x27bf7a.license || "Unknown";
40
+ const _0x3a52c7 = _0x27bf7a.repository ? _0x27bf7a.repository.url || "Not available" : "Not available";
41
+ let _0x1a1dc5 = "\n*SUBZERO NPM SEARCH*\n\n\n*๐Ÿ”ฐNPM PACKAGE :* " + _0x71d130 + "\n\n*๐Ÿ“„DESCRIPTION :* " + _0x4a0adb + "\n\n*โธ๏ธ LAST VERSION :* " + _0x39dfb0 + "\n\n*๐Ÿชช LICENSE :* " + _0x1f70c0 + "\n\n*๐ŸชฉREPOSITORY :* " + _0x3a52c7 + "\n\n*๐Ÿ”—NPM URL :* " + _0x484c23 + "\n\n";
42
+ const _0x25a4fa = {
43
+ text: _0x1a1dc5
44
+ };
45
+ const _0x4ab6e6 = {
46
+ quoted: _0x534cf5
47
+ };
48
+ await _0x45c3e3.sendMessage(_0x4a8b86, _0x25a4fa, _0x4ab6e6);
49
+ } catch (_0x5b358e) {
50
+ console.error(_0x5b358e);
51
+ _0x5ddb6d("An error occurred: " + _0x5b358e.message);
52
+ }
53
+ });