Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@lvckyworld/marina-api

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lvckyworld/marina-api - npm Package Compare versions

Comparing version
2.0.1
to
2.0.2
+6
-21
.gitlab-ci.yml

@@ -10,7 +10,7 @@ stages:

- '/deployment/.rsync.yml'
- '/package_manager/.npm.yml'
- component: git.lvckyworld.dev/pipeline-components/node-package-manager/npm-install@~latest
- component: git.lvckyworld.dev/pipeline-components/node-package-manager/publish-npm-package@~latest
npm install:
stage: build
extends: .npm-install
extends: .npm install
script:

@@ -29,20 +29,3 @@ - ls -la

publish to npm:
stage: publish
extends: npm install
artifacts:
expire_in: 1 week
only:
- /^(deploy-prod-)\d{8}.\d{4}$/
script:
- rm -r tools
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
- npm whoami
- ls -la
- chmod +x ./npm-publish.sh
- ./npm-publish.sh
cache:
key: ${CI_COMMIT_REF_SLUG}-${CI_PROJECT_ID}
paths:
- ./lib/
policy: pull
extends: .publish to npm

@@ -52,2 +35,4 @@ deploy documentation:

extends: .deploy-rsync
needs:
- publish to npm
environment:

@@ -54,0 +39,0 @@ name: 'production'

{
"name": "@lvckyworld/marina-api",
"version": "2.0.1",
"version": "2.0.2",
"main": "lib/MarinaAPI.js",

@@ -5,0 +5,0 @@ "types": "lib/MarinaAPI.d.ts",

export class MainConfig {
public static readonly API_URL = 'https://marina.lvckyworld.net/';
public static readonly API_URL = 'https://marina.lvckyworld.net';
}
export declare class MainConfig {
static readonly API_URL = "https://marina.lvckyworld.net/";
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MainConfig = void 0;
var MainConfig = /** @class */ (function () {
function MainConfig() {
}
MainConfig.API_URL = 'https://marina.lvckyworld.net/';
return MainConfig;
}());
exports.MainConfig = MainConfig;
import { ErrorResponseBody, SuccessResponseBody } from "../LWRequest";
export declare class LvckyWorldRequest {
/**
* Sends a GET request to the given API endpoint using the specified base URL.
*
* @param {string} baseUrl - The base URL of the API.
* @param {string} apiEndpoint - The endpoint of the API.
* @returns {Promise<SuccessResponseBody | ErrorResponseBody>} - The response body containing the data or error from the API.
*/
protected sendGetRequest(baseUrl: string, apiEndpoint: string): Promise<SuccessResponseBody | ErrorResponseBody>;
/**
* Sends a POST request to the specified API endpoint with the given parameters.
* @param {string} baseUrl - The base URL of the API
* @param {string} apiEndpoint - The specific endpoint of the API
* @param {string} apiToken - The API token used for authentication
* @param {any|null} params - The parameters to be sent with the request (optional)
* @return {Promise<SuccessResponseBody|ErrorResponseBody>} - The response body of the request
*/
protected sendPostRequest(baseUrl: string, apiEndpoint: string, apiToken: string, params?: any | null): Promise<SuccessResponseBody | ErrorResponseBody>;
/**
* Sends a PUT request to the specified API endpoint.
*
* @param {string} baseUrl - The base URL of the API.
* @param {string} apiEndpoint - The endpoint of the API.
* @param {string} apiToken - The API token to authorize the request.
* @param {any | null} params - Optional parameters to be included in the request body.
* @return {Promise<SuccessResponseBody | ErrorResponseBody>} - The promise that resolves to the response body.
*/
protected sendPutRequest(baseUrl: string, apiEndpoint: string, apiToken: string, params?: any | null): Promise<SuccessResponseBody | ErrorResponseBody>;
/**
* Sends a DELETE request to the specified API endpoint with the given parameters and API token.
* Returns a promise that resolves to the success or error response body.
*
* @param {string | null} baseUrl - The base URL for the API (optional).
* @param {string} apiEndpoint - The API endpoint to send the DELETE request to.
* @param {string} apiToken - The API token to include in the request headers.
* @param {any | null} params - The parameters to include in the request URL (optional).
* @returns {Promise<SuccessResponseBody | ErrorResponseBody>} A promise that resolves to the response body.
*/
protected sendDeleteRequest(baseUrl: string | null | undefined, apiEndpoint: string, apiToken: string, params?: any | null): Promise<SuccessResponseBody | ErrorResponseBody>;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LvckyWorldRequest = void 0;
var axios_1 = require("axios");
var LvckyWorldRequest = /** @class */ (function () {
function LvckyWorldRequest() {
}
/**
* Sends a GET request to the given API endpoint using the specified base URL.
*
* @param {string} baseUrl - The base URL of the API.
* @param {string} apiEndpoint - The endpoint of the API.
* @returns {Promise<SuccessResponseBody | ErrorResponseBody>} - The response body containing the data or error from the API.
*/
LvckyWorldRequest.prototype.sendGetRequest = function (baseUrl, apiEndpoint) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, axios_1.default.get((baseUrl) + apiEndpoint)];
});
});
};
/**
* Sends a POST request to the specified API endpoint with the given parameters.
* @param {string} baseUrl - The base URL of the API
* @param {string} apiEndpoint - The specific endpoint of the API
* @param {string} apiToken - The API token used for authentication
* @param {any|null} params - The parameters to be sent with the request (optional)
* @return {Promise<SuccessResponseBody|ErrorResponseBody>} - The response body of the request
*/
LvckyWorldRequest.prototype.sendPostRequest = function (baseUrl_1, apiEndpoint_1, apiToken_1) {
return __awaiter(this, arguments, void 0, function (baseUrl, apiEndpoint, apiToken, params) {
if (params === void 0) { params = null; }
return __generator(this, function (_a) {
return [2 /*return*/, axios_1.default.post((baseUrl) + apiEndpoint, { params: params, headers: { Authorization: "Bearer " + apiToken } })];
});
});
};
/**
* Sends a PUT request to the specified API endpoint.
*
* @param {string} baseUrl - The base URL of the API.
* @param {string} apiEndpoint - The endpoint of the API.
* @param {string} apiToken - The API token to authorize the request.
* @param {any | null} params - Optional parameters to be included in the request body.
* @return {Promise<SuccessResponseBody | ErrorResponseBody>} - The promise that resolves to the response body.
*/
LvckyWorldRequest.prototype.sendPutRequest = function (baseUrl_1, apiEndpoint_1, apiToken_1) {
return __awaiter(this, arguments, void 0, function (baseUrl, apiEndpoint, apiToken, params) {
if (params === void 0) { params = null; }
return __generator(this, function (_a) {
return [2 /*return*/, axios_1.default.put((baseUrl) + apiEndpoint, { params: params, headers: { Authorization: "Bearer " + apiToken } })];
});
});
};
/**
* Sends a DELETE request to the specified API endpoint with the given parameters and API token.
* Returns a promise that resolves to the success or error response body.
*
* @param {string | null} baseUrl - The base URL for the API (optional).
* @param {string} apiEndpoint - The API endpoint to send the DELETE request to.
* @param {string} apiToken - The API token to include in the request headers.
* @param {any | null} params - The parameters to include in the request URL (optional).
* @returns {Promise<SuccessResponseBody | ErrorResponseBody>} A promise that resolves to the response body.
*/
LvckyWorldRequest.prototype.sendDeleteRequest = function () {
return __awaiter(this, arguments, void 0, function (baseUrl, apiEndpoint, apiToken, params) {
if (baseUrl === void 0) { baseUrl = null; }
if (params === void 0) { params = null; }
return __generator(this, function (_a) {
return [2 /*return*/, axios_1.default.delete((baseUrl) + apiEndpoint, { params: params, headers: { Authorization: "Bearer " + apiToken } })];
});
});
};
return LvckyWorldRequest;
}());
exports.LvckyWorldRequest = LvckyWorldRequest;
/**
* Represents a list of LvckyWorld team members.
* @interface
*/
export interface TeamMember {
member_name: string;
member_id: string;
highest_role_id: string;
highest_role_name: string;
highest_role_position: number;
sort_id: number;
is_admin: boolean;
}
/**
* Represents a collection of LvckyWorld GlobalBans.
* @interface
*/
export interface GlobalBans {
globalbans: [
GlobalBan
];
}
/**
* Represents a LvckyWorld GlobalBan.
* @interface
*/
export interface GlobalBan {
member_id: string;
member_avatar: string;
member_name: string;
ban_reason: string;
ban_creator_id: string;
ban_creator_name: string;
banned_on_guild_name: string;
banned_on_guild_id: string;
timestamp: string;
special_permit: boolean;
}
/**
* Represents the schema for an old global ban.
* @interface OldGlobalBanSchema
*/
export interface OldGlobalBanSchema {
clientid: string;
clientavatar: string;
clientname: string;
banreason: string;
bancreatorid: string;
bancreatorname: string;
bannedOn: string;
timestamp: string;
permis: boolean;
}
/**
* Represents a member in Discord.
* @interface
*/
export interface DiscordUserData {
id: string;
username: string;
avatar: string | null;
discriminator: string;
public_flags: number | null;
premium_type: number | null;
flags: number | null;
global_name: string | null;
avatar_decoration_data: string | null;
banner: string | null;
banner_color: string | null;
accent_color: string | null;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export interface ErrorResponseBody {
success: false;
error: string;
errorCode: string;
}
export interface SuccessResponseBody {
success: true;
data: any;
}
"use strict";
/*
* ©2016-2024 LvckyWorld - by LvckyAPI all Rights reserved
* Licensed to Iven Schlenther, Lukas Oetken and Michal Oblong
* Project: lvckyworld-api
*/
Object.defineProperty(exports, "__esModule", { value: true });
import { LWPostRequests } from "./requestTypes/PostRequest";
import { LWPutRequests } from "./requestTypes/PutRequest";
import { LWDeleteRequest } from "./requestTypes/LWDeleteRequest";
import { LWGetRequest } from "./requestTypes/LWGetRequest";
/**
* Represents a class for making requests to the LvckyWorld API.
*/
export declare class Request {
private apiToken;
private apiUrl;
constructor(apiToken?: string, apiUrl?: string);
get(): LWGetRequest;
post(): LWPostRequests;
put(): LWPutRequests;
delete(): LWDeleteRequest;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Request = void 0;
var MainConfig_1 = require("../config/MainConfig");
var PostRequest_1 = require("./requestTypes/PostRequest");
var PutRequest_1 = require("./requestTypes/PutRequest");
var LWDeleteRequest_1 = require("./requestTypes/LWDeleteRequest");
var LWGetRequest_1 = require("./requestTypes/LWGetRequest");
/**
* Represents a class for making requests to the LvckyWorld API.
*/
var Request = /** @class */ (function () {
function Request(apiToken, apiUrl) {
if (apiToken === void 0) { apiToken = 'NOT SET'; }
if (apiUrl === void 0) { apiUrl = MainConfig_1.MainConfig.API_URL; }
this.apiToken = apiToken;
this.apiUrl = apiUrl;
}
Request.prototype.get = function () {
return new LWGetRequest_1.LWGetRequest(this.apiUrl);
};
Request.prototype.post = function () {
return new PostRequest_1.LWPostRequests(this.apiUrl, this.apiToken);
};
Request.prototype.put = function () {
return new PutRequest_1.LWPutRequests(this.apiUrl, this.apiToken);
};
Request.prototype.delete = function () {
return new LWDeleteRequest_1.LWDeleteRequest(this.apiUrl, this.apiToken);
};
return Request;
}());
exports.Request = Request;
import { LvckyWorldRequest } from "../../contract/abstract/LvckyWorldRequest";
import { GlobalBan } from "../../contract/ApiData";
/**
* Represents a class for making delete requests to the LvckyWorld API.
*/
export declare class LWDeleteRequest extends LvckyWorldRequest {
private apiUrl;
private apiToken;
/**
* Creates a new instance of the Constructor class.
* @param {string} apiUrl - The URL of the API.
* @param {string} apiToken - The authentication token for the API.
*/
constructor(apiUrl: string, apiToken: string);
/**
* Deletes the global ban of a member.
*
* @param {string} memberId - The ID of the member to delete the global ban for.
* @returns {Promise<GlobalBan>} A promise that resolves with the deleted global ban.
* @throws {Error} If the request to delete the global ban fails.
*/
deleteGlobalBan(memberId: string): Promise<GlobalBan>;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LWDeleteRequest = void 0;
var LvckyWorldRequest_1 = require("../../contract/abstract/LvckyWorldRequest");
/**
* Represents a class for making delete requests to the LvckyWorld API.
*/
var LWDeleteRequest = /** @class */ (function (_super) {
__extends(LWDeleteRequest, _super);
/**
* Creates a new instance of the Constructor class.
* @param {string} apiUrl - The URL of the API.
* @param {string} apiToken - The authentication token for the API.
*/
function LWDeleteRequest(apiUrl, apiToken) {
var _this = _super.call(this) || this;
_this.apiUrl = apiUrl;
_this.apiToken = apiToken;
return _this;
}
/**
* Deletes the global ban of a member.
*
* @param {string} memberId - The ID of the member to delete the global ban for.
* @returns {Promise<GlobalBan>} A promise that resolves with the deleted global ban.
* @throws {Error} If the request to delete the global ban fails.
*/
LWDeleteRequest.prototype.deleteGlobalBan = function (memberId) {
return __awaiter(this, void 0, void 0, function () {
var request;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.sendDeleteRequest(this.apiUrl, '/globalbans/' + memberId, this.apiToken)];
case 1:
request = _b.sent();
if (request.success) {
return [2 /*return*/, request.data];
}
throw (_a = request.error) !== null && _a !== void 0 ? _a : request;
}
});
});
};
return LWDeleteRequest;
}(LvckyWorldRequest_1.LvckyWorldRequest));
exports.LWDeleteRequest = LWDeleteRequest;
import { LvckyWorldRequest } from "../../contract/abstract/LvckyWorldRequest";
import { DiscordUserData, GlobalBan, GlobalBans, TeamMember } from "../../contract/ApiData";
import { Snowflake } from "discord-api-types/globals";
/**
* Represents a class for making put requests to the LvckyWorld API.
*/
export declare class LWGetRequest extends LvckyWorldRequest {
private apiUrl;
/**
* Creates an instance of the constructor.
* @param {string} apiUrl - The URL of the API to be used.
* @constructor
*/
constructor(apiUrl: string);
/**
* Retrieves global bans from the specified API endpoint.
* @returns {Promise<GlobalBans>} A promise that resolves to the response data containing global bans.
*/
getGlobalBans(): Promise<GlobalBans>;
/**
* Retrieves the global ban information for a given member.
* @param {Snowflake} memberId - The ID of the member whose global ban information is to be retrieved.
* @return {Promise<GlobalBan>} A promise that resolves with the global ban information (if found) or rejects with an error.
*/
getGlobalBan(memberId: Snowflake): Promise<GlobalBan>;
/**
* Retrieves the LvckyWorld team members from the API.
* @returns {Promise<TeamMember[]>} A promise that resolves with the LvckyWorld team members.
* @throws {Error} If there was an error while retrieving the team members.
*/
getLvckyWorldMembers(): Promise<TeamMember[]>;
/**
* Retrieves the list of system administrators.
* @returns {Promise<TeamMember[]>} A promise that resolves with an array of system administrators (TeamMember objects).
* @throws {any} If an error occurs while fetching the data.
*/
getSystemAdmins(): Promise<TeamMember[]>;
/**
* Retrieves user information from the server using the provided member ID.
* @param {string} memberId - The unique identifier of the member.
* @return {Promise<DiscordUserData>} - A promise that resolves with the retrieved DiscordMember object.
* @throws {Error} - If an error occurs during the retrieval process.
*/
getUserInfo(memberId: Snowflake): Promise<DiscordUserData>;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LWGetRequest = void 0;
var LvckyWorldRequest_1 = require("../../contract/abstract/LvckyWorldRequest");
var axios = require("axios");
/**
* Represents a class for making put requests to the LvckyWorld API.
*/
var LWGetRequest = /** @class */ (function (_super) {
__extends(LWGetRequest, _super);
/**
* Creates an instance of the constructor.
* @param {string} apiUrl - The URL of the API to be used.
* @constructor
*/
function LWGetRequest(apiUrl) {
var _this = _super.call(this) || this;
_this.apiUrl = apiUrl;
return _this;
}
/**
* Retrieves global bans from the specified API endpoint.
* @returns {Promise<GlobalBans>} A promise that resolves to the response data containing global bans.
*/
LWGetRequest.prototype.getGlobalBans = function () {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var response, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.sendGetRequest(this.apiUrl, '/globalbans')];
case 1:
response = _a.sent();
if (!response.success)
return [2 /*return*/, reject(response.error)];
return [2 /*return*/, resolve(response.data)];
case 2:
error_1 = _a.sent();
return [2 /*return*/, reject(error_1)];
case 3: return [2 /*return*/];
}
});
}); })];
});
});
};
/**
* Retrieves the global ban information for a given member.
* @param {Snowflake} memberId - The ID of the member whose global ban information is to be retrieved.
* @return {Promise<GlobalBan>} A promise that resolves with the global ban information (if found) or rejects with an error.
*/
LWGetRequest.prototype.getGlobalBan = function (memberId) {
var _this = this;
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var response, error_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, axios.default.get(this.apiUrl + '/globalbans/' + memberId)];
case 1:
response = _a.sent();
return [2 /*return*/, resolve(response.data)];
case 2:
error_2 = _a.sent();
return [2 /*return*/, reject(error_2)];
case 3: return [2 /*return*/];
}
});
}); });
};
/**
* Retrieves the LvckyWorld team members from the API.
* @returns {Promise<TeamMember[]>} A promise that resolves with the LvckyWorld team members.
* @throws {Error} If there was an error while retrieving the team members.
*/
LWGetRequest.prototype.getLvckyWorldMembers = function () {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var response, error_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, axios.default.get(this.apiUrl + '/team-members')];
case 1:
response = _a.sent();
return [2 /*return*/, resolve(response.data)];
case 2:
error_3 = _a.sent();
return [2 /*return*/, reject(error_3)];
case 3: return [2 /*return*/];
}
});
}); })];
});
});
};
/**
* Retrieves the list of system administrators.
* @returns {Promise<TeamMember[]>} A promise that resolves with an array of system administrators (TeamMember objects).
* @throws {any} If an error occurs while fetching the data.
*/
LWGetRequest.prototype.getSystemAdmins = function () {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var response, data, error_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.sendGetRequest(this.apiUrl, '/team-members')];
case 1:
response = _a.sent();
if (!response.success)
return [2 /*return*/, reject(response.error)];
data = response.data;
return [2 /*return*/, resolve(data.filter((function (member) { return member.is_admin; })))];
case 2:
error_4 = _a.sent();
return [2 /*return*/, reject(error_4)];
case 3: return [2 /*return*/];
}
});
}); })];
});
});
};
/**
* Retrieves user information from the server using the provided member ID.
* @param {string} memberId - The unique identifier of the member.
* @return {Promise<DiscordUserData>} - A promise that resolves with the retrieved DiscordMember object.
* @throws {Error} - If an error occurs during the retrieval process.
*/
LWGetRequest.prototype.getUserInfo = function (memberId) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var response, error_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.sendGetRequest(this.apiUrl, '/users/' + memberId)];
case 1:
response = _a.sent();
if (!response.success)
return [2 /*return*/, reject(response.error)];
return [2 /*return*/, resolve(response.data)];
case 2:
error_5 = _a.sent();
return [2 /*return*/, reject(error_5)];
case 3: return [2 /*return*/];
}
});
}); })];
});
});
};
return LWGetRequest;
}(LvckyWorldRequest_1.LvckyWorldRequest));
exports.LWGetRequest = LWGetRequest;
import { LvckyWorldRequest } from "../../contract/abstract/LvckyWorldRequest";
import { GlobalBan } from "../../contract/ApiData";
/**
* Represents a class for making post requests to the LvckyWorld API.
*/
export declare class LWPostRequests extends LvckyWorldRequest {
private apiUrl;
private apiToken;
constructor(apiUrl: string, apiToken: string);
/**
* Creates a global ban for a member.
*
* @param {string} memberId - The ID of the member being banned.
* @param {string} banReason - The reason for the ban.
* @param {string} banCreatorId - The ID of the user creating the ban.
* @param {string} bannedOnGuildName - The name of the guild where the ban took place.
* @param {string} bannedOnGuildId - The ID of the guild where the ban took place.
* @returns {Promise<GlobalBan>} A promise that resolves with the created global ban object.
* @throws {Error} If the request fails or returns an error.
*/
createGlobalBan(memberId: string, banReason: string, banCreatorId: string, bannedOnGuildName: string, bannedOnGuildId: string): Promise<GlobalBan>;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LWPostRequests = void 0;
var LvckyWorldRequest_1 = require("../../contract/abstract/LvckyWorldRequest");
/**
* Represents a class for making post requests to the LvckyWorld API.
*/
var LWPostRequests = /** @class */ (function (_super) {
__extends(LWPostRequests, _super);
function LWPostRequests(apiUrl, apiToken) {
var _this = _super.call(this) || this;
_this.apiUrl = apiUrl;
_this.apiToken = apiToken;
return _this;
}
/**
* Creates a global ban for a member.
*
* @param {string} memberId - The ID of the member being banned.
* @param {string} banReason - The reason for the ban.
* @param {string} banCreatorId - The ID of the user creating the ban.
* @param {string} bannedOnGuildName - The name of the guild where the ban took place.
* @param {string} bannedOnGuildId - The ID of the guild where the ban took place.
* @returns {Promise<GlobalBan>} A promise that resolves with the created global ban object.
* @throws {Error} If the request fails or returns an error.
*/
LWPostRequests.prototype.createGlobalBan = function (memberId, banReason, banCreatorId, bannedOnGuildName, bannedOnGuildId) {
return __awaiter(this, void 0, void 0, function () {
var request;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.sendPostRequest(this.apiUrl, '/globalbans', this.apiToken, {
member_id: memberId,
ban_reason: banReason,
ban_creator_id: banCreatorId,
banned_on_guild_name: bannedOnGuildName,
banned_on_guild_id: bannedOnGuildId,
})];
case 1:
request = _b.sent();
if (request.success) {
return [2 /*return*/, request.data];
}
throw (_a = request.error) !== null && _a !== void 0 ? _a : request;
}
});
});
};
return LWPostRequests;
}(LvckyWorldRequest_1.LvckyWorldRequest));
exports.LWPostRequests = LWPostRequests;
import { LvckyWorldRequest } from "../../contract/abstract/LvckyWorldRequest";
import { GlobalBan } from "../../contract/ApiData";
/**
* Represents a class for making put requests to the LvckyWorld API.
*/
export declare class LWPutRequests extends LvckyWorldRequest {
private apiUrl;
private apiToken;
constructor(apiUrl: string, apiToken: string);
/**
* Edits a global ban.
*
* @param {string | null} banReason - The reason for the ban. Defaults to null.
* @param {string | null} specialPermit - The special permit for the ban. Defaults to null.
* @returns {Promise<GlobalBan>} - A Promise that resolves with the edited global ban.
* @throws {Error} - If the request fails or an error occurs.
*/
editGlobalBan(banReason?: string | null, specialPermit?: string | null): Promise<GlobalBan>;
/**
* Changes the ban reason for a global ban.
*
* @param {string} banReason - The new ban reason.
* @return {Promise<GlobalBan>} - A promise that resolves to the updated GlobalBan object.
* @throws {any} - Throws the error object returned by the API or the original request object if no error is provided.
*/
changeBanReason(banReason: string): Promise<GlobalBan>;
/**
* Changes the special permit status of a global ban.
*
* @param {boolean} specialPermit - The new special permit status. True to enable, false to disable.
* @returns {Promise<GlobalBan>} - A promise that resolves to the updated global ban object.
* @throws {Error} - An error is thrown if the request fails or if the response is unsuccessful.
*/
changeSpecialPermit(specialPermit: boolean): Promise<GlobalBan>;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LWPutRequests = void 0;
var LvckyWorldRequest_1 = require("../../contract/abstract/LvckyWorldRequest");
/**
* Represents a class for making put requests to the LvckyWorld API.
*/
var LWPutRequests = /** @class */ (function (_super) {
__extends(LWPutRequests, _super);
function LWPutRequests(apiUrl, apiToken) {
var _this = _super.call(this) || this;
_this.apiUrl = apiUrl;
_this.apiToken = apiToken;
return _this;
}
/**
* Edits a global ban.
*
* @param {string | null} banReason - The reason for the ban. Defaults to null.
* @param {string | null} specialPermit - The special permit for the ban. Defaults to null.
* @returns {Promise<GlobalBan>} - A Promise that resolves with the edited global ban.
* @throws {Error} - If the request fails or an error occurs.
*/
LWPutRequests.prototype.editGlobalBan = function () {
return __awaiter(this, arguments, void 0, function (banReason, specialPermit) {
var params, request;
var _a;
if (banReason === void 0) { banReason = null; }
if (specialPermit === void 0) { specialPermit = null; }
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
params = {
ban_reason: banReason,
special_permit: specialPermit
};
return [4 /*yield*/, this.sendPostRequest(this.apiUrl, '/globalbans', this.apiToken, params)];
case 1:
request = _b.sent();
if (request.success) {
return [2 /*return*/, request.data];
}
throw (_a = request.error) !== null && _a !== void 0 ? _a : request;
}
});
});
};
/**
* Changes the ban reason for a global ban.
*
* @param {string} banReason - The new ban reason.
* @return {Promise<GlobalBan>} - A promise that resolves to the updated GlobalBan object.
* @throws {any} - Throws the error object returned by the API or the original request object if no error is provided.
*/
LWPutRequests.prototype.changeBanReason = function (banReason) {
return __awaiter(this, void 0, void 0, function () {
var request;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.sendPutRequest(this.apiUrl, '/globalbans', this.apiToken, {
ban_reason: banReason
})];
case 1:
request = _b.sent();
if (request.success) {
return [2 /*return*/, request.data];
}
throw (_a = request.error) !== null && _a !== void 0 ? _a : request;
}
});
});
};
/**
* Changes the special permit status of a global ban.
*
* @param {boolean} specialPermit - The new special permit status. True to enable, false to disable.
* @returns {Promise<GlobalBan>} - A promise that resolves to the updated global ban object.
* @throws {Error} - An error is thrown if the request fails or if the response is unsuccessful.
*/
LWPutRequests.prototype.changeSpecialPermit = function (specialPermit) {
return __awaiter(this, void 0, void 0, function () {
var request;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, this.sendPutRequest(this.apiUrl, '/globalbans', this.apiToken, {
special_permit: specialPermit
})];
case 1:
request = _b.sent();
if (request.success) {
return [2 /*return*/, request.data];
}
throw (_a = request.error) !== null && _a !== void 0 ? _a : request;
}
});
});
};
return LWPutRequests;
}(LvckyWorldRequest_1.LvckyWorldRequest));
exports.LWPutRequests = LWPutRequests;
import { Request } from "./core/Request";
import { Snowflake } from "discord-api-types/globals";
import { DiscordUserData, GlobalBans, TeamMember } from "./contract/ApiData";
/**
* The MarinaAPI class provides functions to interact with the Marina API.
* @extends Request
*/
export declare class MarinaAPI extends Request {
constructor(apiToken?: string, apiURL?: string);
/**
* Checks if the given member ID is a LvckyWorld admin.
* @param {Snowflake} memberId - The member ID to check.
* @return {Promise<boolean>} - A promise that resolves to a boolean value indicating if the member is a LvckyWorld admin.
*/
isLvckyWorldAdmin(memberId: Snowflake): Promise<boolean>;
/**
* Checks if a member is globally banned.
* @param {Snowflake} memberId - The ID of the member to check.
* @return {Promise<boolean>} - A promise that resolves to true if the member is globally banned, false otherwise.
*/
isGlobalBanned(memberId: Snowflake): Promise<boolean>;
/**
* Retrieves the global ban list from LvckyWorld.
* @returns {Promise<GlobalBans>} A promise that resolves with the global ban list.
*/
getGlobalBanList(): Promise<GlobalBans>;
/**
* Retrieves the administrators of LvckyWorld.
* @returns {Promise<TeamMember[]>} A promise that resolves to an array of Lvcky World admins.
*/
getLvckyWorldAdmins(): Promise<TeamMember[]>;
/**
* Retrieve LvckyWorld team members.
* @returns {Promise<TeamMember[]>} - A promise that resolves to an array of Lucky World members.
*/
getLvckyWorldTeam(): Promise<TeamMember[]>;
/**
* Checks if a member is a Lvcky World team member.
* @param {Snowflake} memberId - The ID of the member to check.
* @return {Promise<boolean>} - A promise that resolves to a boolean indicating if the member is a Lvcky World team member.
*/
isLvckyWorldTeamMember(memberId: Snowflake): Promise<boolean>;
/**
* Retrieves a Discord member's information based on their ID.
* @param {Snowflake} memberId - The ID of the Discord member.
* @return {Promise<DiscordUserData>} A promise that resolves with the Discord member's information.
*/
getDiscordMember(memberId: Snowflake): Promise<DiscordUserData>;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MarinaAPI = void 0;
var Request_1 = require("./core/Request");
var MainConfig_1 = require("./config/MainConfig");
/**
* The MarinaAPI class provides functions to interact with the Marina API.
* @extends Request
*/
var MarinaAPI = /** @class */ (function (_super) {
__extends(MarinaAPI, _super);
function MarinaAPI(apiToken, apiURL) {
if (apiToken === void 0) { apiToken = 'NOT SET'; }
if (apiURL === void 0) { apiURL = MainConfig_1.MainConfig.API_URL; }
return _super.call(this, apiToken, apiURL) || this;
}
/**
* Checks if the given member ID is a LvckyWorld admin.
* @param {Snowflake} memberId - The member ID to check.
* @return {Promise<boolean>} - A promise that resolves to a boolean value indicating if the member is a LvckyWorld admin.
*/
MarinaAPI.prototype.isLvckyWorldAdmin = function (memberId) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = resolve;
return [4 /*yield*/, this.getLvckyWorldAdmins()];
case 1: return [2 /*return*/, _a.apply(void 0, [(_b.sent()).some(function (admin) { return admin.member_id === memberId; })])];
}
});
}); })];
});
});
};
/**
* Checks if a member is globally banned.
* @param {Snowflake} memberId - The ID of the member to check.
* @return {Promise<boolean>} - A promise that resolves to true if the member is globally banned, false otherwise.
*/
MarinaAPI.prototype.isGlobalBanned = function (memberId) {
var _this = this;
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = resolve;
return [4 /*yield*/, this.get().getGlobalBan(memberId)];
case 1: return [2 /*return*/, _a.apply(void 0, [(_b.sent()) !== null])];
}
});
}); });
};
/**
* Retrieves the global ban list from LvckyWorld.
* @returns {Promise<GlobalBans>} A promise that resolves with the global ban list.
*/
MarinaAPI.prototype.getGlobalBanList = function () {
var _this = this;
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = resolve;
return [4 /*yield*/, this.get().getGlobalBans()];
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
}
});
}); });
};
/**
* Retrieves the administrators of LvckyWorld.
* @returns {Promise<TeamMember[]>} A promise that resolves to an array of Lvcky World admins.
*/
MarinaAPI.prototype.getLvckyWorldAdmins = function () {
var _this = this;
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = resolve;
return [4 /*yield*/, this.get().getLvckyWorldMembers()];
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
}
});
}); });
};
/**
* Retrieve LvckyWorld team members.
* @returns {Promise<TeamMember[]>} - A promise that resolves to an array of Lucky World members.
*/
MarinaAPI.prototype.getLvckyWorldTeam = function () {
var _this = this;
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = resolve;
return [4 /*yield*/, this.get().getLvckyWorldMembers()];
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
}
});
}); });
};
/**
* Checks if a member is a Lvcky World team member.
* @param {Snowflake} memberId - The ID of the member to check.
* @return {Promise<boolean>} - A promise that resolves to a boolean indicating if the member is a Lvcky World team member.
*/
MarinaAPI.prototype.isLvckyWorldTeamMember = function (memberId) {
var _this = this;
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = resolve;
return [4 /*yield*/, this.get().getLvckyWorldMembers()];
case 1: return [2 /*return*/, _a.apply(void 0, [(_b.sent()).some(function (member) { return member.member_id === memberId; })])];
}
});
}); });
};
/**
* Retrieves a Discord member's information based on their ID.
* @param {Snowflake} memberId - The ID of the Discord member.
* @return {Promise<DiscordUserData>} A promise that resolves with the Discord member's information.
*/
MarinaAPI.prototype.getDiscordMember = function (memberId) {
var _this = this;
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = resolve;
return [4 /*yield*/, this.get().getUserInfo(memberId)];
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
}
});
}); });
};
return MarinaAPI;
}(Request_1.Request));
exports.MarinaAPI = MarinaAPI;