lgcord.js
Advanced tools
Comparing version 1.0.0 to 2.1.0
{ | ||
"name": "lgcord.js", | ||
"version": "1.0.0", | ||
"version": "2.1.0", | ||
"description": "LGcord.js", | ||
"main": "./output/index.js", | ||
"types": "./output/index.d.ts", | ||
"scripts": { | ||
"build": "npx tsc" | ||
}, | ||
"main": "./src/index.js", | ||
"types": "./src/index.d.ts", | ||
"author": "tga098", | ||
@@ -11,0 +8,0 @@ "license": "MIT", |
<h1 align="center">LGcord.Js</h1> | ||
<img src="https://cdn.discordapp.com/attachments/972146644067971153/1027552655112945724/1665058019810.png" size="50%"> | ||
<img src="https://media.discordapp.net/attachments/913066109081620570/1051116162026573904/1665301818603_1.png"> | ||
@@ -35,25 +35,3 @@ > **A Nodejs Discord API wrapper. This is a small library that allows you to interact with Discord API to make discord bots** | ||
# Events Available: | ||
- messageCreate *reply to a message or get info a message sent/receieved by the bot* | ||
- messageDelete *get info of a message when deleted* | ||
- messageUpdate *get info of a message if it gets updated/edited* | ||
*MORE EVENTS DOCS WILL BE ADDED* | ||
Embed Example: | ||
```js | ||
const { DiscordEmbed } = require("lgcord.js") | ||
let embed = new DiscordEmbed() | ||
.setTitle("Hello World") | ||
.setColor("Color") | ||
.setDescription('Bot using lgcord.js') | ||
.setFooter('Footer') | ||
.setTimestamp() | ||
``` | ||
# Documentation | ||
> Documentation avaiable at https://lgcordjs.logixdev.net |
"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 __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
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 (_) 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 }; | ||
} | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createGlobalApplicationCommand = exports.deleteAllReactions = exports.deleteUserReaction = exports.addReaction = exports.editMessage = exports.createMessage = exports.interactionCallback = exports.getGatewayBot = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
var node_fetch_1 = require("node-fetch"); | ||
var discord_message_1 = require("../data-objects/discord-message"); | ||
var __1 = require(".."); | ||
var discord_gateway_bot_info_1 = require("../data-objects/discord-gateway-bot-info"); | ||
var URL_BASE = 'https://discord.com/api/v8'; | ||
var requestQueue = Promise.resolve(); | ||
var requestQueueLen = 0; | ||
var bucketMap = {}; | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const discord_message_1 = require("../data-objects/discord-message"); | ||
const __1 = require(".."); | ||
const discord_gateway_bot_info_1 = require("../data-objects/discord-gateway-bot-info"); | ||
const URL_BASE = 'https://discord.com/api/v8'; | ||
let requestQueue = Promise.resolve(); | ||
let requestQueueLen = 0; | ||
const bucketMap = {}; | ||
function timeout(ms) { | ||
return new Promise(function (resolve) { return setTimeout(resolve, ms); }); | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
function sendFetch(url, urlGroup, init) { | ||
return new Promise(function (resolve, reject) { return queueReq(url, urlGroup, resolve, reject, init); }); | ||
return new Promise((resolve, reject) => queueReq(url, urlGroup, resolve, reject, init)); | ||
} | ||
function queueReq(url, urlGroup, resolve, reject, init) { | ||
var _this = this; | ||
requestQueueLen++; | ||
requestQueue = requestQueue.then(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, processQueue(url, urlGroup, resolve, reject, init)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); }); })["finally"](function () { return requestQueueLen--; }); | ||
requestQueue = requestQueue.then(async () => await processQueue(url, urlGroup, resolve, reject, init)).finally(() => requestQueueLen--); | ||
} | ||
function processQueue(url, urlGroup, resolve, reject, init) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var bucketInfo, now, holdTime, globalWait, resp; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (bucketMap[urlGroup]) { | ||
bucketInfo = bucketMap[urlGroup]; | ||
if (bucketInfo.remain == 0) { | ||
now = Date.now(); | ||
if (now <= (bucketInfo.resetTime + 2) * 1000) { | ||
holdTime = ((bucketInfo.resetTime + 2) * 1000) - now; | ||
setTimeout(function () { | ||
queueReq(url, urlGroup, resolve, reject, init); | ||
}, holdTime); | ||
return [2 /*return*/]; | ||
} | ||
} | ||
} | ||
globalWait = -1; | ||
return [4 /*yield*/, (0, node_fetch_1["default"])("".concat(URL_BASE).concat(url), init).then(function (r) { return __awaiter(_this, void 0, void 0, function () { | ||
var bucket, oldBucket; | ||
var _a, _b, _c, _d, _e; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
case 0: | ||
bucket = r.headers.get('x-ratelimit-bucket'); | ||
oldBucket = (_a = bucketMap[urlGroup]) === null || _a === void 0 ? void 0 : _a.bucket; | ||
bucketMap[urlGroup] = { | ||
bucket: bucket, | ||
limit: parseInt((_b = r.headers.get('x-ratelimit-limit')) !== null && _b !== void 0 ? _b : '0'), | ||
remain: parseInt((_c = r.headers.get('x-ratelimit-remaining')) !== null && _c !== void 0 ? _c : '0'), | ||
resetTime: parseInt((_d = r.headers.get('x-ratelimit-reset')) !== null && _d !== void 0 ? _d : '0'), | ||
resetAfter: parseInt((_e = r.headers.get('x-ratelimit-reset-after')) !== null && _e !== void 0 ? _e : '0') | ||
}; | ||
if (oldBucket && oldBucket !== bucket) | ||
console.log('ERROR! Bucket mismatch! ', urlGroup, bucketMap[urlGroup].bucket, bucket); | ||
if (!r.headers.get('X-RateLimit-Global')) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, resp.json().then(function (json) { return globalWait = json.retry_after * 1000; })]; | ||
case 1: | ||
_f.sent(); | ||
_f.label = 2; | ||
case 2: | ||
if (r.headers.get('X-RateLimit-Scope')) { | ||
console.log('Rate limit! ', r.headers.get('X-RateLimit-Scope')); | ||
console.log('\tInfo: ', bucketMap[urlGroup]); | ||
console.log('\tReq: ', "".concat(URL_BASE).concat(url)); | ||
console.log('\tGroup: ', urlGroup); | ||
} | ||
return [2 /*return*/, r]; | ||
} | ||
}); | ||
}); })]; | ||
case 1: | ||
resp = _a.sent(); | ||
if (!(globalWait != -1)) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, timeout(globalWait)]; | ||
case 2: | ||
_a.sent(); | ||
_a.label = 3; | ||
case 3: | ||
resolve(resp); | ||
return [2 /*return*/]; | ||
async function processQueue(url, urlGroup, resolve, reject, init) { | ||
if (bucketMap[urlGroup]) { | ||
const bucketInfo = bucketMap[urlGroup]; | ||
if (bucketInfo.remain == 0) { | ||
const now = Date.now(); | ||
if (now <= (bucketInfo.resetTime + 2) * 1000) { | ||
const holdTime = ((bucketInfo.resetTime + 2) * 1000) - now; | ||
setTimeout(() => { | ||
queueReq(url, urlGroup, resolve, reject, init); | ||
}, holdTime); | ||
return; | ||
} | ||
}); | ||
} | ||
} | ||
let globalWait = -1; | ||
const resp = await (0, node_fetch_1.default)(`${URL_BASE}${url}`, init).then(async (r) => { | ||
const bucket = r.headers.get('x-ratelimit-bucket'); | ||
const oldBucket = bucketMap[urlGroup]?.bucket; | ||
bucketMap[urlGroup] = { | ||
bucket: bucket, | ||
limit: parseInt(r.headers.get('x-ratelimit-limit') ?? '0'), | ||
remain: parseInt(r.headers.get('x-ratelimit-remaining') ?? '0'), | ||
resetTime: parseInt(r.headers.get('x-ratelimit-reset') ?? '0'), | ||
resetAfter: parseInt(r.headers.get('x-ratelimit-reset-after') ?? '0'), | ||
}; | ||
if (oldBucket && oldBucket !== bucket) | ||
console.log('ERROR! Bucket mismatch! ', urlGroup, bucketMap[urlGroup].bucket, bucket); | ||
if (r.headers.get('X-RateLimit-Global')) | ||
await resp.json().then(json => globalWait = json.retry_after * 1000); | ||
if (r.headers.get('X-RateLimit-Scope')) { | ||
console.log('Rate limit! ', r.headers.get('X-RateLimit-Scope')); | ||
console.log('\tInfo: ', bucketMap[urlGroup]); | ||
console.log('\tReq: ', `${URL_BASE}${url}`); | ||
console.log('\tGroup: ', urlGroup); | ||
} | ||
return r; | ||
}); | ||
if (globalWait != -1) | ||
await timeout(globalWait); | ||
resolve(resp); | ||
} | ||
function getGatewayBot() { | ||
var url = '/gateway/bot'; | ||
const url = '/gateway/bot'; | ||
return sendFetch(url, url, { | ||
method: 'GET', | ||
headers: { | ||
'authorization': "Bot ".concat(__1.DiscordMinimal.token), | ||
'Content-Type': 'application/json' | ||
'authorization': `Bot ${__1.Client.token}`, | ||
'Content-Type': 'application/json', | ||
} | ||
}).then(function (resp) { | ||
}).then(resp => { | ||
if (resp.ok) | ||
return resp.json().then(function (json) { return new discord_gateway_bot_info_1.DiscordGatewayBotInfo(json); }); | ||
return resp.json().then(function (json) { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
return resp.json().then(json => new discord_gateway_bot_info_1.DiscordGatewayBotInfo(json)); | ||
return resp.json().then(json => { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
}); | ||
@@ -149,14 +83,14 @@ } | ||
function interactionCallback(interactionId, interactionToken, data) { | ||
var url = "".concat(URL_BASE, "/interactions/").concat(interactionId, "/").concat(interactionToken, "/callback"); | ||
return (0, node_fetch_1["default"])(url, { | ||
const url = `${URL_BASE}/interactions/${interactionId}/${interactionToken}/callback`; | ||
return (0, node_fetch_1.default)(url, { | ||
method: 'POST', | ||
headers: { | ||
'authorization': "Bot ".concat(__1.DiscordMinimal.token), | ||
'Content-Type': 'application/json' | ||
'authorization': `Bot ${__1.Client.token}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(data) | ||
}).then(function (resp) { | ||
body: JSON.stringify(data), | ||
}).then(resp => { | ||
if (resp.ok) | ||
return new Promise(function (resolve) { return resolve(); }); | ||
return resp.json().then(function (json) { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
return new Promise(resolve => resolve()); | ||
return resp.json().then(json => { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
}); | ||
@@ -166,14 +100,14 @@ } | ||
function createMessage(channelId, message) { | ||
var url = "/channels/".concat(channelId, "/messages"); | ||
return sendFetch(url, "/channels/".concat(channelId, "/messages/create"), { | ||
const url = `/channels/${channelId}/messages`; | ||
return sendFetch(url, `/channels/${channelId}/messages/create`, { | ||
method: 'POST', | ||
headers: { | ||
'authorization': "Bot ".concat(__1.DiscordMinimal.token), | ||
'Content-Type': 'application/json' | ||
'authorization': `Bot ${__1.Client.token}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(message) | ||
}).then(function (resp) { | ||
body: JSON.stringify(message), | ||
}).then(resp => { | ||
if (resp.ok) | ||
return resp.json().then(discord_message_1.DiscordMessage.fromJson); | ||
return resp.json().then(function (json) { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
return resp.json().then(json => { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
}); | ||
@@ -183,14 +117,14 @@ } | ||
function editMessage(channelId, messagelId, message) { | ||
var url = "/channels/".concat(channelId, "/messages/").concat(messagelId); | ||
return sendFetch(url, "/channels/".concat(channelId, "/messages/edit"), { | ||
const url = `/channels/${channelId}/messages/${messagelId}`; | ||
return sendFetch(url, `/channels/${channelId}/messages/edit`, { | ||
method: 'PATCH', | ||
headers: { | ||
'authorization': "Bot ".concat(__1.DiscordMinimal.token), | ||
'Content-Type': 'application/json' | ||
'authorization': `Bot ${__1.Client.token}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(message) | ||
}).then(function (resp) { | ||
body: JSON.stringify(message), | ||
}).then(resp => { | ||
if (resp.ok) | ||
return resp.json().then(discord_message_1.DiscordMessage.fromJson); | ||
return resp.json().then(function (json) { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
return resp.json().then(json => { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
}); | ||
@@ -200,13 +134,13 @@ } | ||
function addReaction(channelId, messagelId, emoji) { | ||
var url = "/channels/".concat(channelId, "/messages/").concat(messagelId, "/reactions/").concat(encodeURIComponent(emoji), "/@me"); | ||
return sendFetch(url, "/channels/".concat(channelId, "/messages/reactions"), { | ||
const url = `/channels/${channelId}/messages/${messagelId}/reactions/${encodeURIComponent(emoji)}/@me`; | ||
return sendFetch(url, `/channels/${channelId}/messages/reactions`, { | ||
method: 'PUT', | ||
headers: { | ||
'authorization': "Bot ".concat(__1.DiscordMinimal.token), | ||
'Content-Type': 'application/json' | ||
'authorization': `Bot ${__1.Client.token}`, | ||
'Content-Type': 'application/json', | ||
} | ||
}).then(function (resp) { | ||
}).then(resp => { | ||
if (resp.ok) | ||
return new Promise(function (resolve) { return resolve(); }); | ||
return resp.json().then(function (json) { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
return new Promise(resolve => resolve()); | ||
return resp.json().then(json => { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
}); | ||
@@ -216,13 +150,13 @@ } | ||
function deleteUserReaction(channelId, messagelId, emoji, userId) { | ||
var url = "/channels/".concat(channelId, "/messages/").concat(messagelId, "/reactions/").concat(encodeURIComponent(emoji), "/").concat(userId); | ||
return sendFetch(url, "/channels/".concat(channelId, "/messages/reactions"), { | ||
const url = `/channels/${channelId}/messages/${messagelId}/reactions/${encodeURIComponent(emoji)}/${userId}`; | ||
return sendFetch(url, `/channels/${channelId}/messages/reactions`, { | ||
method: 'DELETE', | ||
headers: { | ||
'authorization': "Bot ".concat(__1.DiscordMinimal.token), | ||
'Content-Type': 'application/json' | ||
'authorization': `Bot ${__1.Client.token}`, | ||
'Content-Type': 'application/json', | ||
} | ||
}).then(function (resp) { | ||
}).then(resp => { | ||
if (resp.ok) | ||
return new Promise(function (resolve) { return resolve(); }); | ||
return resp.json().then(function (json) { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
return new Promise(resolve => resolve()); | ||
return resp.json().then(json => { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
}); | ||
@@ -232,13 +166,13 @@ } | ||
function deleteAllReactions(channelId, messagelId) { | ||
var url = "/channels/".concat(channelId, "/messages/").concat(messagelId, "/reactions"); | ||
return sendFetch(url, "/channels/".concat(channelId, "/messages/reactions"), { | ||
const url = `/channels/${channelId}/messages/${messagelId}/reactions`; | ||
return sendFetch(url, `/channels/${channelId}/messages/reactions`, { | ||
method: 'DELETE', | ||
headers: { | ||
'authorization': "Bot ".concat(__1.DiscordMinimal.token), | ||
'Content-Type': 'application/json' | ||
'authorization': `Bot ${__1.Client.token}`, | ||
'Content-Type': 'application/json', | ||
} | ||
}).then(function (resp) { | ||
}).then(resp => { | ||
if (resp.ok) | ||
return new Promise(function (resolve) { return resolve(); }); | ||
return resp.json().then(function (json) { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
return new Promise(resolve => resolve()); | ||
return resp.json().then(json => { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
}); | ||
@@ -248,16 +182,16 @@ } | ||
function createGlobalApplicationCommand(command) { | ||
var url = "/applications/".concat(command.application_id, "/commands"); | ||
return sendFetch(url, "/applications/".concat(command.application_id, "/commands"), { | ||
const url = `/applications/${command.application_id}/commands`; | ||
return sendFetch(url, `/applications/${command.application_id}/commands`, { | ||
method: 'POST', | ||
headers: { | ||
'authorization': "Bot ".concat(__1.DiscordMinimal.token), | ||
'Content-Type': 'application/json' | ||
'authorization': `Bot ${__1.Client.token}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(command) | ||
}).then(function (resp) { | ||
body: JSON.stringify(command), | ||
}).then(resp => { | ||
if (resp.ok) | ||
return new Promise(function (resolve) { return resolve(); }); | ||
return resp.json().then(function (json) { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
return new Promise(resolve => resolve()); | ||
return resp.json().then(json => { throw new __1.DiscordAPIError(json.code, json.message, json.errors, url); }); | ||
}); | ||
} | ||
exports.createGlobalApplicationCommand = createGlobalApplicationCommand; |
"use strict"; | ||
exports.__esModule = true; | ||
var RateLimitBucket = /** @class */ (function () { | ||
function RateLimitBucket() { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class RateLimitBucket { | ||
constructor() { | ||
this.bucket = ''; | ||
@@ -11,4 +11,3 @@ this.limit = 0; | ||
} | ||
return RateLimitBucket; | ||
}()); | ||
exports["default"] = RateLimitBucket; | ||
} | ||
exports.default = RateLimitBucket; |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WebSocketData = void 0; | ||
var WebSocketData = /** @class */ (function () { | ||
function WebSocketData(ws, shard) { | ||
class WebSocketData { | ||
constructor(ws, shard) { | ||
this.resume = false; | ||
this.resume_url = ''; | ||
this.session_id = ''; | ||
@@ -12,4 +13,3 @@ this.seq = -1; | ||
} | ||
return WebSocketData; | ||
}()); | ||
} | ||
exports.WebSocketData = WebSocketData; |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordAPIError = void 0; | ||
var DiscordAPIError = /** @class */ (function () { | ||
function DiscordAPIError(code, message, errors, endpoint) { | ||
class DiscordAPIError { | ||
constructor(code, message, errors, method, endpoint) { | ||
this.code = code; | ||
this.message = message; | ||
this.errors = errors; | ||
this.method = method; | ||
this.endpoint = endpoint; | ||
} | ||
return DiscordAPIError; | ||
}()); | ||
} | ||
exports.DiscordAPIError = DiscordAPIError; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
var DiscordApplicationCommandInteractionDataOption = /** @class */ (function () { | ||
function DiscordApplicationCommandInteractionDataOption(name, type) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordApplicationCommandInteractionDataOption { | ||
constructor(name, type) { | ||
this.name = name; | ||
this.type = type; | ||
} | ||
DiscordApplicationCommandInteractionDataOption.fromJson = function (json) { | ||
var _a; | ||
var newInst = new DiscordApplicationCommandInteractionDataOption(json.name, json.type); | ||
static fromJson(json) { | ||
const newInst = new DiscordApplicationCommandInteractionDataOption(json.name, json.type); | ||
newInst.value = json.value; | ||
newInst.options = (_a = json.options) === null || _a === void 0 ? void 0 : _a.map(DiscordApplicationCommandInteractionDataOption.fromJson); | ||
newInst.options = json.options?.map(DiscordApplicationCommandInteractionDataOption.fromJson); | ||
newInst.focused = json.focused; | ||
return newInst; | ||
}; | ||
return DiscordApplicationCommandInteractionDataOption; | ||
}()); | ||
exports["default"] = DiscordApplicationCommandInteractionDataOption; | ||
} | ||
} | ||
exports.default = DiscordApplicationCommandInteractionDataOption; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordApplicationCommandOptionChoiceStructure = void 0; | ||
var DiscordApplicationCommandOptionChoiceStructure = /** @class */ (function () { | ||
function DiscordApplicationCommandOptionChoiceStructure(name, value) { | ||
class DiscordApplicationCommandOptionChoiceStructure { | ||
constructor(name, value) { | ||
this.name = name; | ||
this.value = value; | ||
} | ||
DiscordApplicationCommandOptionChoiceStructure.fromJson = function (json) { | ||
var newInst = new DiscordApplicationCommandOptionChoiceStructure(json.name, json.value); | ||
static fromJson(json) { | ||
const newInst = new DiscordApplicationCommandOptionChoiceStructure(json.name, json.value); | ||
return newInst; | ||
}; | ||
return DiscordApplicationCommandOptionChoiceStructure; | ||
}()); | ||
} | ||
} | ||
exports.DiscordApplicationCommandOptionChoiceStructure = DiscordApplicationCommandOptionChoiceStructure; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordApplicationCommandOption = void 0; | ||
var discord_application_command_option_choice_structure_1 = require("./discord-application-command-option-choice-structure"); | ||
var DiscordApplicationCommandOption = /** @class */ (function () { | ||
function DiscordApplicationCommandOption(name, description, type) { | ||
this.choices = []; // Types for the user to pick from, max 25 | ||
this.options = []; // Array of application command option if the option is a subcommand or subcommand group type, these nested options will be the parameters | ||
this.channel_types = []; // If the option is a channel type, the channels shown will be restricted to these types | ||
const discord_application_command_option_choice_structure_1 = require("./discord-application-command-option-choice-structure"); | ||
class DiscordApplicationCommandOption { | ||
constructor(name, description, type) { | ||
/** | ||
* Types for the user to pick from, max 25 | ||
*/ | ||
this.choices = []; | ||
/** | ||
* Array of application command option if the option is a subcommand or subcommand group type, these nested options will be the parameters | ||
*/ | ||
this.options = []; | ||
/** | ||
* If the option is a channel type, the channels shown will be restricted to these types | ||
*/ | ||
this.channel_types = []; | ||
this.name = name; | ||
@@ -16,9 +25,8 @@ this.description = description; | ||
} | ||
DiscordApplicationCommandOption.fromJson = function (json) { | ||
var _a, _b, _c, _d, _e; | ||
var newInst = new DiscordApplicationCommandOption(json.name, json.description, json.type); | ||
static fromJson(json) { | ||
const newInst = new DiscordApplicationCommandOption(json.name, json.description, json.type); | ||
newInst.required = json.required; | ||
newInst.choices = (_b = (_a = json.choices) === null || _a === void 0 ? void 0 : _a.map(discord_application_command_option_choice_structure_1.DiscordApplicationCommandOptionChoiceStructure.fromJson)) !== null && _b !== void 0 ? _b : []; | ||
newInst.options = (_d = (_c = json.options) === null || _c === void 0 ? void 0 : _c.map(DiscordApplicationCommandOption.fromJson)) !== null && _d !== void 0 ? _d : []; | ||
newInst.channel_types = (_e = json.channel_types) !== null && _e !== void 0 ? _e : []; | ||
newInst.choices = json.choices?.map(discord_application_command_option_choice_structure_1.DiscordApplicationCommandOptionChoiceStructure.fromJson) ?? []; | ||
newInst.options = json.options?.map(DiscordApplicationCommandOption.fromJson) ?? []; | ||
newInst.channel_types = json.channel_types ?? []; | ||
newInst.min_value = json.min_value; | ||
@@ -28,17 +36,16 @@ newInst.max_value = json.max_value; | ||
return newInst; | ||
}; | ||
DiscordApplicationCommandOption.prototype.setRequired = function () { | ||
} | ||
setRequired() { | ||
this.required = true; | ||
return this; | ||
}; | ||
DiscordApplicationCommandOption.prototype.addChoiceKeyVal = function (key, value) { | ||
} | ||
addChoiceKeyVal(key, value) { | ||
this.choices.push(new discord_application_command_option_choice_structure_1.DiscordApplicationCommandOptionChoiceStructure(key, value)); | ||
return this; | ||
}; | ||
DiscordApplicationCommandOption.prototype.addChoice = function (choice) { | ||
} | ||
addChoice(choice) { | ||
this.choices.push(choice); | ||
return this; | ||
}; | ||
return DiscordApplicationCommandOption; | ||
}()); | ||
} | ||
} | ||
exports.DiscordApplicationCommandOption = DiscordApplicationCommandOption; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordApplicationCommand = void 0; | ||
var discord_application_command_type_1 = require("../custom-types/discord-application-command-type"); | ||
var discord_application_command_option_1 = require("./discord-application-command-option"); | ||
const discord_application_command_type_1 = require("../custom-types/discord-application-command-type"); | ||
const discord_application_command_option_1 = require("./discord-application-command-option"); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var DiscordApplicationCommand = /** @class */ (function () { | ||
function DiscordApplicationCommand(application_id, name, description) { | ||
this.options = []; // The parameters for the command, max 25 CHAT_INPUT | ||
class DiscordApplicationCommand { | ||
constructor(application_id, name, description) { | ||
/** | ||
* The parameters for the command, max 25 CHAT_INPUT | ||
*/ | ||
this.options = []; | ||
this.application_id = application_id; | ||
@@ -16,28 +19,21 @@ this.name = name; | ||
} | ||
DiscordApplicationCommand.fromJson = function (json) { | ||
var _a, _b; | ||
var newInst = new DiscordApplicationCommand(json.application_id, json.name, json.description); | ||
static fromJson(json) { | ||
const newInst = new DiscordApplicationCommand(json.application_id, json.name, json.description); | ||
newInst.id = json.id; | ||
newInst.type = json.type; | ||
newInst.guild_id = json.guild_id; | ||
newInst.options = (_b = (_a = json.options) === null || _a === void 0 ? void 0 : _a.map(discord_application_command_option_1.DiscordApplicationCommandOption.fromJson)) !== null && _b !== void 0 ? _b : []; | ||
newInst.options = json.options?.map(discord_application_command_option_1.DiscordApplicationCommandOption.fromJson) ?? []; | ||
newInst.default_permission = json.default_permission; | ||
newInst.version = json.version; | ||
return newInst; | ||
}; | ||
DiscordApplicationCommand.prototype.setType = function (type) { | ||
} | ||
setType(type) { | ||
this.type = type; | ||
return this; | ||
}; | ||
DiscordApplicationCommand.prototype.addOption = function () { | ||
var _a; | ||
var options = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
options[_i] = arguments[_i]; | ||
} | ||
(_a = this.options).push.apply(_a, options); | ||
} | ||
addOption(...options) { | ||
this.options.push(...options); | ||
return this; | ||
}; | ||
return DiscordApplicationCommand; | ||
}()); | ||
} | ||
} | ||
exports.DiscordApplicationCommand = DiscordApplicationCommand; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
var DiscordApplication = /** @class */ (function () { | ||
// name string the name of the app | ||
// icon ?string the icon hash of the app | ||
// description string the description of the app | ||
// rpc_origins? array of strings an array of rpc origin urls, if rpc is enabled | ||
// bot_public boolean when false only app owner can join the app's bot to guilds | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordApplication { | ||
// bot_require_code_grant boolean when true the app's bot will only join upon completion of the full oauth2 code grant flow | ||
@@ -23,11 +18,14 @@ // terms_of_service_url? string the url of the app's terms of service | ||
// flags? integer the application's public flags | ||
function DiscordApplication(id) { | ||
constructor(id, name, description, bot_public) { | ||
this.id = id; | ||
this.name = name; | ||
this.description = description; | ||
this.bot_public = bot_public; | ||
} | ||
DiscordApplication.fromJson = function (json) { | ||
var newInst = new DiscordApplication(json.id); | ||
static fromJson(json) { | ||
const newInst = new DiscordApplication(json.id, json.name, json.description, json.bot_public); | ||
newInst.icon = json.icon; | ||
return newInst; | ||
}; | ||
return DiscordApplication; | ||
}()); | ||
exports["default"] = DiscordApplication; | ||
} | ||
} | ||
exports.default = DiscordApplication; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordComponent = /** @class */ (function () { | ||
function DiscordComponent() { | ||
} | ||
return DiscordComponent; | ||
}()); | ||
exports["default"] = DiscordComponent; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordComponent { | ||
} | ||
exports.default = DiscordComponent; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordEmbedAuthor = /** @class */ (function () { | ||
function DiscordEmbedAuthor(name, url, iconUrl, proxyIconUrl) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordEmbedAuthor { | ||
constructor(name, url, iconUrl, proxyIconUrl) { | ||
this.name = name; | ||
@@ -10,4 +10,3 @@ this.url = url; | ||
} | ||
return DiscordEmbedAuthor; | ||
}()); | ||
exports["default"] = DiscordEmbedAuthor; | ||
} | ||
exports.default = DiscordEmbedAuthor; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordEmbedField = /** @class */ (function () { | ||
function DiscordEmbedField(name, value, inline) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordEmbedField { | ||
constructor(name, value, inline) { | ||
this.name = name; | ||
@@ -9,4 +9,3 @@ this.value = value; | ||
} | ||
return DiscordEmbedField; | ||
}()); | ||
exports["default"] = DiscordEmbedField; | ||
} | ||
exports.default = DiscordEmbedField; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordEmbedFooter = /** @class */ (function () { | ||
function DiscordEmbedFooter(text, iconUrl, proxyIconUrl) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordEmbedFooter { | ||
constructor(text, iconUrl, proxyIconUrl) { | ||
this.text = text; | ||
@@ -9,4 +9,3 @@ this.icon_url = iconUrl; | ||
} | ||
return DiscordEmbedFooter; | ||
}()); | ||
exports["default"] = DiscordEmbedFooter; | ||
} | ||
exports.default = DiscordEmbedFooter; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordEmbedImage = /** @class */ (function () { | ||
function DiscordEmbedImage(url, proxyUrl, height, width) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordEmbedImage { | ||
constructor(url, proxyUrl, height, width) { | ||
this.url = url; | ||
@@ -10,4 +10,3 @@ this.proxy_url = proxyUrl; | ||
} | ||
return DiscordEmbedImage; | ||
}()); | ||
exports["default"] = DiscordEmbedImage; | ||
} | ||
exports.default = DiscordEmbedImage; |
"use strict"; | ||
exports.__esModule = true; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordEmbed = void 0; | ||
var discord_embed_author_1 = require("./discord-embed-author"); | ||
var discord_embed_field_1 = require("./discord-embed-field"); | ||
var discord_embed_footer_1 = require("./discord-embed-footer"); | ||
var discord_embed_image_1 = require("./discord-embed-image"); | ||
var DiscordEmbed = /** @class */ (function () { | ||
function DiscordEmbed() { | ||
this.fields = []; // Array of embed field objects fields information | ||
const discord_embed_author_1 = __importDefault(require("./discord-embed-author")); | ||
const discord_embed_field_1 = __importDefault(require("./discord-embed-field")); | ||
const discord_embed_footer_1 = __importDefault(require("./discord-embed-footer")); | ||
const discord_embed_image_1 = __importDefault(require("./discord-embed-image")); | ||
class DiscordEmbed { | ||
constructor() { | ||
/** | ||
* Array of embed field objects fields information | ||
*/ | ||
this.fields = []; | ||
} | ||
DiscordEmbed.prototype.setColor = function (color) { | ||
setColor(color) { | ||
this.color = typeof color === 'string' ? Number(color) : color; | ||
return this; | ||
}; | ||
DiscordEmbed.prototype.setDescription = function (description) { | ||
} | ||
setDescription(description) { | ||
this.description = description; | ||
return this; | ||
}; | ||
DiscordEmbed.prototype.setTitle = function (title) { | ||
} | ||
setTitle(title) { | ||
this.title = title; | ||
return this; | ||
}; | ||
DiscordEmbed.prototype.setAuthor = function (name, iconUrl, url, proxyIconUrl) { | ||
this.author = new discord_embed_author_1["default"](name, url, iconUrl, proxyIconUrl); | ||
} | ||
setAuthor(name, iconUrl, url, proxyIconUrl) { | ||
this.author = new discord_embed_author_1.default(name, url, iconUrl, proxyIconUrl); | ||
return this; | ||
}; | ||
DiscordEmbed.prototype.setImage = function (url, proxyUrl, height, width) { | ||
this.image = new discord_embed_image_1["default"](url, proxyUrl, height, width); | ||
} | ||
setImage(url, proxyUrl, height, width) { | ||
this.image = new discord_embed_image_1.default(url, proxyUrl, height, width); | ||
return this; | ||
}; | ||
DiscordEmbed.prototype.addField = function (name, value, inline) { | ||
var _a; | ||
(_a = this.fields) === null || _a === void 0 ? void 0 : _a.push(new discord_embed_field_1["default"](name, value, inline)); | ||
} | ||
addField(name, value, inline) { | ||
this.fields?.push(new discord_embed_field_1.default(name, value, inline)); | ||
return this; | ||
}; | ||
DiscordEmbed.prototype.setFooter = function (text, iconUrl, proxyIconUrl) { | ||
this.footer = new discord_embed_footer_1["default"](text, iconUrl, proxyIconUrl); | ||
} | ||
setFooter(text, iconUrl, proxyIconUrl) { | ||
this.footer = new discord_embed_footer_1.default(text, iconUrl, proxyIconUrl); | ||
return this; | ||
}; | ||
DiscordEmbed.prototype.setTimestamp = function () { | ||
} | ||
setTimestamp() { | ||
this.timestamp = new Date().toISOString(); | ||
return this; | ||
}; | ||
return DiscordEmbed; | ||
}()); | ||
} | ||
} | ||
exports.DiscordEmbed = DiscordEmbed; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordEmoji = void 0; | ||
const discord_role_1 = require("./discord-role"); | ||
const discord_user_1 = require("./discord-user"); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var DiscordEmoji = /** @class */ (function () { | ||
function DiscordEmoji() { | ||
} | ||
// roles? array of role object ids roles allowed to use this emoji | ||
// user? user object user that created this emoji | ||
// require_colons? boolean whether this emoji must be wrapped in colons | ||
// managed? boolean whether this emoji is managed | ||
// animated? boolean whether this emoji is animated | ||
// available? boolean whether this emoji can be used, may be false due to loss of Server Boosts | ||
DiscordEmoji.fromJson = function (json) { | ||
var newInst = new DiscordEmoji(); | ||
class DiscordEmoji { | ||
static fromJson(json) { | ||
const newInst = new DiscordEmoji(); | ||
newInst.id = json.id; | ||
newInst.name = json.name; | ||
newInst.roles = json.roles?.map((r) => discord_role_1.DiscordRole.fromJson(r)); | ||
newInst.require_colons = json.require_colons; | ||
newInst.managed = json.managed; | ||
newInst.animated = json.animated; | ||
newInst.available = json.available; | ||
return newInst; | ||
}; | ||
return DiscordEmoji; | ||
}()); | ||
} | ||
} | ||
exports.DiscordEmoji = DiscordEmoji; |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordGatewaySessionStartLimit = exports.DiscordGatewayBotInfo = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var DiscordGatewayBotInfo = /** @class */ (function () { | ||
function DiscordGatewayBotInfo(json) { | ||
var _a; | ||
class DiscordGatewayBotInfo { | ||
constructor(json) { | ||
this.url = json.url; | ||
this.shards = json.shards; | ||
this.session_start_limit = new DiscordGatewaySessionStartLimit((_a = json.session_start_limit) !== null && _a !== void 0 ? _a : {}); | ||
this.session_start_limit = new DiscordGatewaySessionStartLimit(json.session_start_limit ?? {}); | ||
} | ||
return DiscordGatewayBotInfo; | ||
}()); | ||
} | ||
exports.DiscordGatewayBotInfo = DiscordGatewayBotInfo; | ||
var DiscordGatewaySessionStartLimit = /** @class */ (function () { | ||
function DiscordGatewaySessionStartLimit(json) { | ||
class DiscordGatewaySessionStartLimit { | ||
constructor(json) { | ||
this.total = json.total; | ||
@@ -23,4 +21,3 @@ this.remaining = json.remaining; | ||
} | ||
return DiscordGatewaySessionStartLimit; | ||
}()); | ||
} | ||
exports.DiscordGatewaySessionStartLimit = DiscordGatewaySessionStartLimit; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordGuildMember = void 0; | ||
var discord_user_1 = require("./discord-user"); | ||
const discord_user_1 = require("./discord-user"); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var DiscordGuildMember = /** @class */ (function () { | ||
function DiscordGuildMember() { | ||
// public avatar? ?string the member's guild avatar hash | ||
this.roles = []; // Array of role object ids | ||
class DiscordGuildMember { | ||
constructor() { | ||
/** | ||
* Array of role object ids | ||
*/ | ||
this.roles = []; | ||
} | ||
DiscordGuildMember.fromJson = function (json, parentUser) { | ||
var _a; | ||
if (parentUser === void 0) { parentUser = undefined; } | ||
var newInst = new DiscordGuildMember(); | ||
static fromJson(json, parentUser = undefined) { | ||
const newInst = new DiscordGuildMember(); | ||
newInst.user = json.user ? discord_user_1.DiscordUser.fromJson(json.user) : parentUser; | ||
newInst.nick = json.nick; | ||
newInst.roles = (_a = json.roles) !== null && _a !== void 0 ? _a : []; | ||
newInst.avatar = json.avatar; | ||
newInst.roles = json.roles ?? []; | ||
newInst.permissions = json.permissions; | ||
return newInst; | ||
}; | ||
return DiscordGuildMember; | ||
}()); | ||
} | ||
} | ||
exports.DiscordGuildMember = DiscordGuildMember; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordGuild = void 0; | ||
var discord_role_1 = require("./discord-role"); | ||
const discord_channel_1 = require("./discord-channel"); | ||
const discord_guild_memeber_1 = require("./discord-guild-memeber"); | ||
const discord_role_1 = require("./discord-role"); | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var DiscordGuild = /** @class */ (function () { | ||
// member_count? * integer total number of members in this guild | ||
// voice_states? * array of partial voice state objects states of members currently in voice channels; lacks the guild_id key | ||
// members? * array of guild member objects users in the guild | ||
// channels? * array of channel objects channels in the guild | ||
class DiscordGuild { | ||
// threads? * array of channel objects all active threads in the guild that current user has permission to view | ||
@@ -32,3 +30,3 @@ // presences? * array of partial presence update objects presences of the members in the guild, will only include non-offline members if the size is greater than large threshold | ||
// premium_progress_bar_enabled boolean whether the guild has the boost progress bar enabled | ||
function DiscordGuild(id, name, owner_id) { | ||
constructor(id, name, owner_id) { | ||
// region? *** ?string voice region id for the guild (deprecated) | ||
@@ -42,3 +40,6 @@ // afk_channel_id ?snowflake id of afk channel | ||
// explicit_content_filter integer explicit content filter level | ||
this.roles = []; // Roles in the guild | ||
/** | ||
* Roles in the guild | ||
*/ | ||
this.roles = []; | ||
this.id = id; | ||
@@ -48,13 +49,13 @@ this.name = name; | ||
} | ||
DiscordGuild.fromJson = function (json) { | ||
var _a; | ||
var newInst = new DiscordGuild(json.id, json.name, json.owner_id); | ||
static fromJson(json) { | ||
const newInst = new DiscordGuild(json.id, json.name, json.owner_id); | ||
newInst.icon = json.icon; | ||
newInst.icon_hash = json.icon_hash; | ||
newInst.roles = (_a = json.roles) === null || _a === void 0 ? void 0 : _a.map(discord_role_1.DiscordRole.fromJson); | ||
newInst.roles = json.roles?.map(discord_role_1.DiscordRole.fromJson); | ||
newInst.unavailable = json.unavailable; | ||
newInst.members = json.members?.map(discord_guild_memeber_1.DiscordGuildMember.fromJson); | ||
newInst.channels = json.channels?.map(discord_channel_1.DiscordChannel.fromJson); | ||
return newInst; | ||
}; | ||
return DiscordGuild; | ||
}()); | ||
} | ||
} | ||
exports.DiscordGuild = DiscordGuild; |
"use strict"; | ||
exports.__esModule = true; | ||
var discord_application_command_interaction_data_option_1 = require("./discord-application-command-interaction-data-option"); | ||
var discord_interaction_resolved_data_1 = require("./discord-interaction-resolved-data"); | ||
var DiscordInteractionData = /** @class */ (function () { | ||
function DiscordInteractionData(id, name, type) { | ||
this.options = []; // The params + values from the user | ||
this.values = []; // The values the user selected | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const discord_application_command_interaction_data_option_1 = __importDefault(require("./discord-application-command-interaction-data-option")); | ||
const discord_interaction_resolved_data_1 = __importDefault(require("./discord-interaction-resolved-data")); | ||
class DiscordInteractionData { | ||
constructor(id, name, type) { | ||
/** | ||
* The params + values from the user | ||
*/ | ||
this.options = []; | ||
/** | ||
* The values the user selected | ||
*/ | ||
this.values = []; | ||
this.id = id; | ||
@@ -13,7 +22,6 @@ this.name = name; | ||
} | ||
DiscordInteractionData.fromJson = function (json) { | ||
var _a, _b; | ||
var newInst = new DiscordInteractionData(json.id, json.name, json.type); | ||
newInst.resolved = json.resolved && discord_interaction_resolved_data_1["default"].fromJson(json.resolved); | ||
newInst.options = (_b = (_a = json.options) === null || _a === void 0 ? void 0 : _a.map(discord_application_command_interaction_data_option_1["default"].fromJson)) !== null && _b !== void 0 ? _b : []; | ||
static fromJson(json) { | ||
const newInst = new DiscordInteractionData(json.id, json.name, json.type); | ||
newInst.resolved = json.resolved && discord_interaction_resolved_data_1.default.fromJson(json.resolved); | ||
newInst.options = json.options?.map(discord_application_command_interaction_data_option_1.default.fromJson) ?? []; | ||
newInst.custom_id = json.custom_id; | ||
@@ -24,5 +32,4 @@ newInst.component_type = json.component_type; | ||
return newInst; | ||
}; | ||
return DiscordInteractionData; | ||
}()); | ||
exports["default"] = DiscordInteractionData; | ||
} | ||
} | ||
exports.default = DiscordInteractionData; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
var DiscordInteractionResolvedData = /** @class */ (function () { | ||
function DiscordInteractionResolvedData() { | ||
} | ||
DiscordInteractionResolvedData.fromJson = function (json) { | ||
var newInst = new DiscordInteractionResolvedData(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordInteractionResolvedData { | ||
static fromJson(json) { | ||
const newInst = new DiscordInteractionResolvedData(); | ||
newInst.users = json.users; | ||
@@ -15,5 +13,4 @@ newInst.members = json.members; | ||
return newInst; | ||
}; | ||
return DiscordInteractionResolvedData; | ||
}()); | ||
exports["default"] = DiscordInteractionResolvedData; | ||
} | ||
} | ||
exports.default = DiscordInteractionResolvedData; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordInteractionResponseData = /** @class */ (function () { | ||
function DiscordInteractionResponseData() { | ||
} | ||
return DiscordInteractionResponseData; | ||
}()); | ||
exports["default"] = DiscordInteractionResponseData; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordInteractionResponseData { | ||
} | ||
exports.default = DiscordInteractionResponseData; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordInteractionResponse = /** @class */ (function () { | ||
function DiscordInteractionResponse() { | ||
} | ||
return DiscordInteractionResponse; | ||
}()); | ||
exports["default"] = DiscordInteractionResponse; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordInteractionResponse { | ||
} | ||
exports.default = DiscordInteractionResponse; |
"use strict"; | ||
exports.__esModule = true; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordInteraction = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var __1 = require(".."); | ||
var discord_interaction_data_1 = require("./discord-interaction-data"); | ||
var discord_interaction_response_data_1 = require("./discord-interaction-response-data"); | ||
var DiscordAPI = require("../api/discord-api"); | ||
var DiscordInteraction = /** @class */ (function () { | ||
function DiscordInteraction(id, application_id, type, token) { | ||
const __1 = require(".."); | ||
const discord_interaction_data_1 = __importDefault(require("./discord-interaction-data")); | ||
const discord_interaction_response_data_1 = __importDefault(require("./discord-interaction-response-data")); | ||
const DiscordAPI = __importStar(require("../api/discord-api")); | ||
class DiscordInteraction { | ||
constructor(id, application_id, type, token) { | ||
this.id = id; | ||
@@ -17,5 +43,5 @@ this.application_id = application_id; | ||
} | ||
DiscordInteraction.fromJson = function (json) { | ||
var newInst = new DiscordInteraction(json.id, json.application_id, json.type, json.token); | ||
newInst.data = json.data && discord_interaction_data_1["default"].fromJson(json.data); | ||
static fromJson(json) { | ||
const newInst = new DiscordInteraction(json.id, json.application_id, json.type, json.token); | ||
newInst.data = json.data && discord_interaction_data_1.default.fromJson(json.data); | ||
newInst.guild_id = json.guild_id; | ||
@@ -28,39 +54,36 @@ newInst.channel_id = json.channel_id; | ||
return newInst; | ||
}; | ||
DiscordInteraction.prototype.isButton = function () { | ||
var _a; | ||
return ((_a = this.data) === null || _a === void 0 ? void 0 : _a.component_type) == __1.DiscordComponentType.BUTTON; | ||
}; | ||
DiscordInteraction.prototype.isAppCommand = function () { | ||
} | ||
isButton() { | ||
return this.data?.component_type == __1.DiscordComponentType.BUTTON; | ||
} | ||
isAppCommand() { | ||
return this.type == __1.DiscordInteractionType.APPLICATION_COMMAND; | ||
}; | ||
DiscordInteraction.prototype.update = function (data) { | ||
} | ||
update(data) { | ||
return DiscordAPI.interactionCallback(this.id, this.token, { | ||
type: __1.DiscordInteractionCallbackType.UPDATE_MESSAGE, | ||
data: data | ||
data | ||
}); | ||
}; | ||
DiscordInteraction.prototype.respond = function (data) { | ||
} | ||
respond(data) { | ||
return DiscordAPI.interactionCallback(this.id, this.token, { | ||
type: __1.DiscordInteractionCallbackType.CHANNEL_MESSAGE_WITH_SOURCE, | ||
data: data | ||
data | ||
}); | ||
}; | ||
DiscordInteraction.prototype.respondText = function (message) { | ||
var data = new discord_interaction_response_data_1["default"](); | ||
} | ||
respondText(message) { | ||
const data = new discord_interaction_response_data_1.default(); | ||
data.content = message; | ||
return this.respond(data); | ||
}; | ||
DiscordInteraction.prototype.sendMessageInChannel = function (message) { | ||
var _a; | ||
} | ||
sendMessageInChannel(message) { | ||
// -1? Should never call this if the channel_id is not set | ||
return DiscordAPI.createMessage((_a = this.channel_id) !== null && _a !== void 0 ? _a : -1, message); | ||
}; | ||
DiscordInteraction.prototype.deferUpdate = function () { | ||
return DiscordAPI.createMessage(this.channel_id ?? -1, message); | ||
} | ||
deferUpdate() { | ||
return DiscordAPI.interactionCallback(this.id, this.token, { | ||
type: __1.DiscordInteractionCallbackType.DEFERRED_UPDATE_MESSAGE | ||
}); | ||
}; | ||
return DiscordInteraction; | ||
}()); | ||
} | ||
} | ||
exports.DiscordInteraction = DiscordInteraction; |
"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 __()); | ||
}; | ||
})(); | ||
exports.__esModule = true; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordMessageActionRow = void 0; | ||
var discord_component_types_1 = require("../custom-types/discord-component-types"); | ||
var discord_component_1 = require("./discord-component"); | ||
var DiscordMessageActionRow = /** @class */ (function (_super) { | ||
__extends(DiscordMessageActionRow, _super); | ||
function DiscordMessageActionRow() { | ||
var _this = _super.call(this) || this; | ||
_this.components = []; // A list of child components | ||
_super.prototype.type = discord_component_types_1.DiscordComponentType.ACTION_ROW; | ||
return _this; | ||
const discord_component_types_1 = require("../custom-types/discord-component-types"); | ||
const discord_component_1 = __importDefault(require("./discord-component")); | ||
class DiscordMessageActionRow extends discord_component_1.default { | ||
constructor() { | ||
super(); | ||
/** | ||
* A list of child components | ||
*/ | ||
this.components = []; | ||
super.type = discord_component_types_1.DiscordComponentType.ACTION_ROW; | ||
} | ||
DiscordMessageActionRow.prototype.addComponents = function () { | ||
var components = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
components[_i] = arguments[_i]; | ||
} | ||
addComponents(...components) { | ||
this.components = components; | ||
return this; | ||
}; | ||
return DiscordMessageActionRow; | ||
}(discord_component_1["default"])); | ||
} | ||
} | ||
exports.DiscordMessageActionRow = DiscordMessageActionRow; |
"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 __()); | ||
}; | ||
})(); | ||
exports.__esModule = true; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordMessageButton = void 0; | ||
var discord_component_types_1 = require("../custom-types/discord-component-types"); | ||
var discord_component_1 = require("./discord-component"); | ||
var DiscordMessageButton = /** @class */ (function (_super) { | ||
__extends(DiscordMessageButton, _super); | ||
function DiscordMessageButton() { | ||
var _this = _super.call(this) || this; | ||
_this.disabled = false; // Whether the component is disabled, default false | ||
_super.prototype.type = discord_component_types_1.DiscordComponentType.BUTTON; | ||
return _this; | ||
const discord_component_types_1 = require("../custom-types/discord-component-types"); | ||
const discord_component_1 = __importDefault(require("./discord-component")); | ||
class DiscordMessageButton extends discord_component_1.default { | ||
constructor() { | ||
super(); | ||
/** | ||
* Whether the component is disabled, default false | ||
*/ | ||
this.disabled = false; | ||
super.type = discord_component_types_1.DiscordComponentType.BUTTON; | ||
} | ||
DiscordMessageButton.prototype.setCustomId = function (id) { | ||
setCustomId(id) { | ||
this.custom_id = id; | ||
return this; | ||
}; | ||
DiscordMessageButton.prototype.setLabel = function (label) { | ||
} | ||
setLabel(label) { | ||
this.label = label; | ||
return this; | ||
}; | ||
DiscordMessageButton.prototype.setStyle = function (style) { | ||
} | ||
setStyle(style) { | ||
this.style = style; | ||
return this; | ||
}; | ||
return DiscordMessageButton; | ||
}(discord_component_1["default"])); | ||
} | ||
} | ||
exports.DiscordMessageButton = DiscordMessageButton; |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordMessageCreate = void 0; | ||
var DiscordMessageCreate = /** @class */ (function () { | ||
function DiscordMessageCreate() { | ||
} | ||
return DiscordMessageCreate; | ||
}()); | ||
class DiscordMessageCreate { | ||
} | ||
exports.DiscordMessageCreate = DiscordMessageCreate; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordMessageDeleteBulk = void 0; | ||
var DiscordMessageDeleteBulk = /** @class */ (function () { | ||
function DiscordMessageDeleteBulk(ids, channel_id) { | ||
class DiscordMessageDeleteBulk { | ||
constructor(ids, channel_id) { | ||
this.ids = ids; | ||
this.channel_id = channel_id; | ||
} | ||
DiscordMessageDeleteBulk.fromJson = function (json) { | ||
var newInst = new DiscordMessageDeleteBulk(json.ids, json.channel_id); | ||
static fromJson(json) { | ||
const newInst = new DiscordMessageDeleteBulk(json.ids, json.channel_id); | ||
newInst.guild_id = json.guild_id; | ||
return newInst; | ||
}; | ||
return DiscordMessageDeleteBulk; | ||
}()); | ||
} | ||
} | ||
exports.DiscordMessageDeleteBulk = DiscordMessageDeleteBulk; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordMessageDelete = void 0; | ||
var DiscordMessageDelete = /** @class */ (function () { | ||
function DiscordMessageDelete(id, channel_id) { | ||
class DiscordMessageDelete { | ||
constructor(id, channel_id) { | ||
this.id = id; | ||
this.channel_id = channel_id; | ||
} | ||
DiscordMessageDelete.fromJson = function (json) { | ||
var newInst = new DiscordMessageDelete(json.id, json.channel_id); | ||
static fromJson(json) { | ||
const newInst = new DiscordMessageDelete(json.id, json.channel_id); | ||
newInst.guild_id = json.guild_id; | ||
return newInst; | ||
}; | ||
return DiscordMessageDelete; | ||
}()); | ||
} | ||
} | ||
exports.DiscordMessageDelete = DiscordMessageDelete; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordMessageEdit = /** @class */ (function () { | ||
function DiscordMessageEdit() { | ||
} | ||
return DiscordMessageEdit; | ||
}()); | ||
exports["default"] = DiscordMessageEdit; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordMessageEdit { | ||
} | ||
exports.default = DiscordMessageEdit; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordMessageReactionAdd = void 0; | ||
var DiscordAPI = require("../api/discord-api"); | ||
var discord_emoji_1 = require("./discord-emoji"); | ||
var discord_guild_memeber_1 = require("./discord-guild-memeber"); | ||
var DiscordMessageReactionAdd = /** @class */ (function () { | ||
function DiscordMessageReactionAdd(user_id, channel_id, message_id, emoji) { | ||
const DiscordAPI = __importStar(require("../api/discord-api")); | ||
const discord_emoji_1 = require("./discord-emoji"); | ||
const discord_guild_memeber_1 = require("./discord-guild-memeber"); | ||
class DiscordMessageReactionAdd { | ||
constructor(user_id, channel_id, message_id, emoji) { | ||
this.user_id = user_id; | ||
@@ -16,18 +39,15 @@ this.channel_id = channel_id; | ||
} | ||
DiscordMessageReactionAdd.fromJson = function (json) { | ||
var newInst = new DiscordMessageReactionAdd(json.user_id, json.channel_id, json.message_id, discord_emoji_1.DiscordEmoji.fromJson(json.emoji)); | ||
static fromJson(json) { | ||
const newInst = new DiscordMessageReactionAdd(json.user_id, json.channel_id, json.message_id, discord_emoji_1.DiscordEmoji.fromJson(json.emoji)); | ||
newInst.guild_id = json.guild_id; | ||
newInst.member = json.member && discord_guild_memeber_1.DiscordGuildMember.fromJson(json.member); | ||
return newInst; | ||
}; | ||
DiscordMessageReactionAdd.prototype.removeUser = function (userId) { | ||
var _a; | ||
return DiscordAPI.deleteUserReaction(this.channel_id, this.message_id, (_a = this.emoji.name) !== null && _a !== void 0 ? _a : '', userId); | ||
}; | ||
DiscordMessageReactionAdd.prototype.remove = function () { | ||
var _a; | ||
return DiscordAPI.deleteUserReaction(this.channel_id, this.message_id, (_a = this.emoji.name) !== null && _a !== void 0 ? _a : '', this.user_id); | ||
}; | ||
return DiscordMessageReactionAdd; | ||
}()); | ||
} | ||
removeUser(userId) { | ||
return DiscordAPI.deleteUserReaction(this.channel_id, this.message_id, this.emoji.name ?? '', userId); | ||
} | ||
remove() { | ||
return DiscordAPI.deleteUserReaction(this.channel_id, this.message_id, this.emoji.name ?? '', this.user_id); | ||
} | ||
} | ||
exports.DiscordMessageReactionAdd = DiscordMessageReactionAdd; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordMessageRefrence = /** @class */ (function () { | ||
function DiscordMessageRefrence() { | ||
} | ||
return DiscordMessageRefrence; | ||
}()); | ||
exports["default"] = DiscordMessageRefrence; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class DiscordMessageRefrence { | ||
} | ||
exports.default = DiscordMessageRefrence; |
"use strict"; | ||
exports.__esModule = true; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordMessage = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var DiscordAPI = require("../api/discord-api"); | ||
var discord_guild_memeber_1 = require("./discord-guild-memeber"); | ||
var discord_user_1 = require("./discord-user"); | ||
var DiscordMessage = /** @class */ (function () { | ||
const DiscordAPI = __importStar(require("../api/discord-api")); | ||
const Client = require("../lgcord"); | ||
const discord_guild_memeber_1 = require("./discord-guild-memeber"); | ||
const discord_reaction_1 = __importDefault(require("./discord-reaction")); | ||
const discord_user_1 = require("./discord-user"); | ||
const {channel_cache, guild_cache} = require("../client/cache"); | ||
class DiscordMessage { | ||
// public nonce ? integer or string used for validating a message was sent | ||
@@ -25,3 +54,11 @@ // public pinned boolean whether this message is pinned | ||
// public stickers ? array of sticker objects Deprecated the stickers sent with the message | ||
function DiscordMessage(id, channel_id, author, content, timestamp) { | ||
constructor(id, channel_id, author, content, timestamp) { | ||
/** | ||
* Whether this was a TTS message | ||
*/ | ||
this.tts = false; | ||
/** | ||
* Users specifically mentioned in the message | ||
*/ | ||
this.mentions = []; | ||
this.id = id; | ||
@@ -33,16 +70,20 @@ this.channel_id = channel_id; | ||
} | ||
DiscordMessage.fromJson = function (json) { | ||
var _a; | ||
var newInst = new DiscordMessage(json.id, json.channel_id, discord_user_1.DiscordUser.fromJson(json.author), json.content, json.timestamp); | ||
static fromJson(json) { | ||
const newInst = new DiscordMessage(json.id, json.channel_id, discord_user_1.DiscordUser.fromJson(json.author), json.content, json.timestamp); | ||
const cd = channel_cache.get(json.channel_id) | ||
const gd = guild_cache.get(json.guild_id) | ||
newInst.guild_id = json.guild_id; | ||
newInst.member = discord_guild_memeber_1.DiscordGuildMember.fromJson((_a = json.member) !== null && _a !== void 0 ? _a : {}, newInst.author); | ||
newInst.member = discord_guild_memeber_1.DiscordGuildMember.fromJson(json.member ?? {}, newInst.author); | ||
newInst.edited_timestamp = json.edited_timestamp; | ||
newInst.tts = json.tts; | ||
newInst.channel = cd | ||
newInst.guild = gd | ||
newInst.mention_everyone = json.mention_everyone; | ||
newInst.mentions = json.mentions.map(discord_user_1.DiscordUser.fromJson); | ||
newInst.reactions = json.reactions?.map(discord_reaction_1.default.fromJson); | ||
return newInst; | ||
}; | ||
DiscordMessage.prototype.reply = function (message) { | ||
} | ||
reply(message) { | ||
return DiscordAPI.createMessage(this.channel_id, { | ||
content: message, | ||
...message, | ||
message_reference: { | ||
@@ -54,20 +95,19 @@ message_id: this.id, | ||
}); | ||
}; | ||
DiscordMessage.prototype.sendMessageInChannel = function (message) { | ||
} | ||
sendMessageInChannel(message) { | ||
return DiscordAPI.createMessage(this.channel_id, { content: message }); | ||
}; | ||
DiscordMessage.prototype.sendInChannel = function (message) { | ||
} | ||
sendInChannel(message) { | ||
return DiscordAPI.createMessage(this.channel_id, message); | ||
}; | ||
DiscordMessage.prototype.edit = function (message) { | ||
} | ||
edit(message) { | ||
return DiscordAPI.editMessage(this.channel_id, this.id, message); | ||
}; | ||
DiscordMessage.prototype.react = function (emoji) { | ||
} | ||
react(emoji) { | ||
return DiscordAPI.addReaction(this.channel_id, this.id, emoji); | ||
}; | ||
DiscordMessage.prototype.removeAllReactions = function () { | ||
} | ||
removeAllReactions() { | ||
return DiscordAPI.deleteAllReactions(this.channel_id, this.id); | ||
}; | ||
return DiscordMessage; | ||
}()); | ||
} | ||
} | ||
exports.DiscordMessage = DiscordMessage; |
"use strict"; | ||
exports.__esModule = true; | ||
var DiscordReaction = /** @class */ (function () { | ||
function DiscordReaction() { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const discord_emoji_1 = require("./discord-emoji"); | ||
class DiscordReaction { | ||
constructor(count, me, emoji) { | ||
this.count = count; | ||
this.me = me; | ||
this.emoji = emoji; | ||
} | ||
return DiscordReaction; | ||
}()); | ||
exports["default"] = DiscordReaction; | ||
static fromJson(json) { | ||
const reaction = new DiscordReaction(json.count, json.me, discord_emoji_1.DiscordEmoji.fromJson(json.emoji)); | ||
return reaction; | ||
} | ||
} | ||
exports.default = DiscordReaction; |
"use strict"; | ||
exports.__esModule = true; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordReady = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var discord_application_1 = require("./discord-application"); | ||
var discord_guild_1 = require("./discord-guild"); | ||
var discord_user_1 = require("./discord-user"); | ||
var DiscordReady = /** @class */ (function () { | ||
function DiscordReady(json) { | ||
const discord_application_1 = __importDefault(require("./discord-application")); | ||
const discord_guild_1 = require("./discord-guild"); | ||
const discord_user_1 = require("./discord-user"); | ||
class DiscordReady { | ||
constructor(json) { | ||
this.v = json.v; | ||
@@ -15,7 +18,7 @@ this.user = discord_user_1.DiscordUser.fromJson(json.user); | ||
this.session_id = json.session_id; | ||
this.resume_gateway_url = json.resume_gateway_url; | ||
this.shard = json.shard; | ||
this.application = discord_application_1["default"].fromJson(json.application); | ||
this.application = discord_application_1.default.fromJson(json.application); | ||
} | ||
return DiscordReady; | ||
}()); | ||
} | ||
exports.DiscordReady = DiscordReady; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordRole = void 0; | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var DiscordRole = /** @class */ (function () { | ||
class DiscordRole { | ||
// managed boolean whether this role is managed by an integration | ||
// mentionable boolean whether this role is mentionable | ||
// tags? role tags object the tags this role has | ||
function DiscordRole(id, name, permissions) { | ||
constructor(id, name, permissions, color, hoist, position) { | ||
this.id = id; | ||
this.name = name; | ||
this.permissions = permissions; | ||
this.color = color; | ||
this.hoist = hoist; | ||
this.position = position; | ||
} | ||
DiscordRole.fromJson = function (json) { | ||
var newInst = new DiscordRole(json.id, json.name, json.permissions); | ||
static fromJson(json) { | ||
const newInst = new DiscordRole(json.id, json.name, json.permissions, json.color, json.hoist, json.position); | ||
newInst.icon = json.icon; | ||
newInst.unicode_emoji = json.unicode_emoji; | ||
return newInst; | ||
}; | ||
return DiscordRole; | ||
}()); | ||
} | ||
} | ||
exports.DiscordRole = DiscordRole; |
"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 __()); | ||
}; | ||
})(); | ||
exports.__esModule = true; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordSelectMenu = void 0; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
var discord_component_types_1 = require("../custom-types/discord-component-types"); | ||
var discord_component_1 = require("./discord-component"); | ||
var DiscordSelectMenu = /** @class */ (function (_super) { | ||
__extends(DiscordSelectMenu, _super); | ||
function DiscordSelectMenu() { | ||
var _this = _super.call(this) || this; | ||
_this.disabled = false; // Whether the component is disabled, default false | ||
_this.options = []; // The choices in the select, max 25 | ||
_super.prototype.type = discord_component_types_1.DiscordComponentType.SELECT_MENU; | ||
return _this; | ||
const discord_component_types_1 = require("../custom-types/discord-component-types"); | ||
const discord_component_1 = __importDefault(require("./discord-component")); | ||
class DiscordSelectMenu extends discord_component_1.default { | ||
constructor() { | ||
super(); | ||
/** | ||
* Whether the component is disabled, default false | ||
*/ | ||
this.disabled = false; | ||
/** | ||
* The choices in the select, max 25 | ||
*/ | ||
this.options = []; | ||
/** | ||
* The minimum number of items that must be chosen; default 1, min 0, max 25 | ||
*/ | ||
this.min_values = 1; | ||
/** | ||
* The maximum number of items that can be chosen; default 1, max 25 | ||
*/ | ||
this.max_values = 1; | ||
super.type = discord_component_types_1.DiscordComponentType.SELECT_MENU; | ||
} | ||
DiscordSelectMenu.prototype.addOptions = function () { | ||
var options = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
options[_i] = arguments[_i]; | ||
} | ||
addOptions(...options) { | ||
this.options = options; | ||
return this; | ||
}; | ||
DiscordSelectMenu.prototype.setCustomId = function (id) { | ||
} | ||
setCustomId(id) { | ||
this.custom_id = id; | ||
return this; | ||
}; | ||
return DiscordSelectMenu; | ||
}(discord_component_1["default"])); | ||
} | ||
} | ||
exports.DiscordSelectMenu = DiscordSelectMenu; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordSelectOption = void 0; | ||
var discord_emoji_1 = require("./discord-emoji"); | ||
var DiscordSelectOption = /** @class */ (function () { | ||
function DiscordSelectOption(label, value) { | ||
const discord_emoji_1 = require("./discord-emoji"); | ||
class DiscordSelectOption { | ||
constructor(label, value) { | ||
this.label = label; | ||
this.value = value; | ||
} | ||
DiscordSelectOption.fromJson = function (json) { | ||
var newInst = new DiscordSelectOption(json.label, json.value); | ||
static fromJson(json) { | ||
const newInst = new DiscordSelectOption(json.label, json.value); | ||
newInst.description = json.description; | ||
newInst.emoji = json.emoji && discord_emoji_1.DiscordEmoji.fromJson(json.emoji); | ||
newInst["default"] = json["default"]; | ||
newInst.default = json.default; | ||
return newInst; | ||
}; | ||
DiscordSelectOption.prototype.setDescription = function (description) { | ||
} | ||
setDescription(description) { | ||
this.description = description; | ||
return this; | ||
}; | ||
DiscordSelectOption.prototype.setEmoji = function (emoji) { | ||
} | ||
setEmoji(emoji) { | ||
this.emoji = emoji; | ||
return this; | ||
}; | ||
DiscordSelectOption.prototype.setDefault = function (def) { | ||
if (def === void 0) { def = true; } | ||
this["default"] = def; | ||
} | ||
setDefault(def = true) { | ||
this.default = def; | ||
return this; | ||
}; | ||
return DiscordSelectOption; | ||
}()); | ||
} | ||
} | ||
exports.DiscordSelectOption = DiscordSelectOption; |
"use strict"; | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiscordUser = void 0; | ||
var DiscordUser = /** @class */ (function () { | ||
// public avatar ? string the user's avatar hash identify | ||
// public bot ? boolean whether the user belongs to an OAuth2 application identify | ||
class DiscordUser { | ||
// public system ? boolean whether the user is an Official Discord System user(part of the urgent message system) identify | ||
@@ -19,3 +17,3 @@ // public mfa_enabled ? boolean whether the user has two factor enabled on their account identify | ||
// public public_flags ? integer the public flags on a user's account identify | ||
function DiscordUser(id, username, discriminator) { | ||
constructor(id, username, discriminator) { | ||
this.id = id; | ||
@@ -25,11 +23,14 @@ this.username = username; | ||
} | ||
DiscordUser.fromJson = function (json) { | ||
var newInst = new DiscordUser(json.id, json.username, json.discriminator); | ||
static fromJson(json) { | ||
const newInst = new DiscordUser(json.id, json.username, json.discriminator); | ||
newInst.avatar = json.avatar; | ||
newInst.bot = json.bot; | ||
return newInst; | ||
}; | ||
DiscordUser.prototype.setActivity = function (activity) { | ||
//TODO | ||
}; | ||
return DiscordUser; | ||
}()); | ||
} | ||
setActivity(activity) { | ||
const rejectedPromise = new Promise((resolve, reject) => { | ||
reject('.setActivity() is not functional yet'); | ||
}); | ||
} | ||
} | ||
exports.DiscordUser = DiscordUser; |
@@ -16,3 +16,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./discord-api-error"), exports); | ||
@@ -19,0 +19,0 @@ __exportStar(require("./discord-application-command"), exports); |
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GatewayPayload = void 0; | ||
var GatewayPayload = /** @class */ (function () { | ||
function GatewayPayload() { | ||
class GatewayPayload { | ||
constructor() { | ||
this.op = -1; | ||
} | ||
return GatewayPayload; | ||
}()); | ||
} | ||
exports.GatewayPayload = GatewayPayload; |
"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 __()); | ||
}; | ||
})(); | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HeartBeatPayload = void 0; | ||
var gateway_payload_1 = require("./gateway-payload"); | ||
var HeartBeatPayload = /** @class */ (function (_super) { | ||
__extends(HeartBeatPayload, _super); | ||
function HeartBeatPayload(seq) { | ||
var _this = _super.call(this) || this; | ||
_this.op = 1; | ||
_this.d = seq == -1 ? null : seq; | ||
return _this; | ||
const gateway_payload_1 = require("./gateway-payload"); | ||
class HeartBeatPayload extends gateway_payload_1.GatewayPayload { | ||
constructor(seq) { | ||
super(); | ||
this.op = 1; | ||
this.d = seq == -1 ? null : seq; | ||
} | ||
return HeartBeatPayload; | ||
}(gateway_payload_1.GatewayPayload)); | ||
} | ||
exports.HeartBeatPayload = HeartBeatPayload; |
"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 __()); | ||
}; | ||
})(); | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IdentifyPayload = void 0; | ||
var gateway_payload_1 = require("./gateway-payload"); | ||
var IdentifyPayload = /** @class */ (function (_super) { | ||
__extends(IdentifyPayload, _super); | ||
function IdentifyPayload(token, intents, shard) { | ||
var _this = _super.call(this) || this; | ||
_this.op = 2; | ||
_this.d = { | ||
const gateway_payload_1 = require("./gateway-payload"); | ||
class IdentifyPayload extends gateway_payload_1.GatewayPayload { | ||
constructor(token, intents, shard) { | ||
super(); | ||
this.op = 2; | ||
this.d = { | ||
token: token, | ||
@@ -33,8 +17,6 @@ intents: intents, | ||
$device: 'discord-minimal' | ||
} | ||
}, | ||
}; | ||
return _this; | ||
} | ||
return IdentifyPayload; | ||
}(gateway_payload_1.GatewayPayload)); | ||
} | ||
exports.IdentifyPayload = IdentifyPayload; |
@@ -16,3 +16,3 @@ "use strict"; | ||
}; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./gateway-payload"), exports); | ||
@@ -19,0 +19,0 @@ __exportStar(require("./heartbeat-payload"), exports); |
"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 __()); | ||
}; | ||
})(); | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResumePayload = void 0; | ||
var gateway_payload_1 = require("./gateway-payload"); | ||
var ResumePayload = /** @class */ (function (_super) { | ||
__extends(ResumePayload, _super); | ||
function ResumePayload(token, session_id, seq) { | ||
var _this = _super.call(this) || this; | ||
_this.op = 6; | ||
_this.d = { | ||
token: token, | ||
session_id: session_id, | ||
seq: seq | ||
const gateway_payload_1 = require("./gateway-payload"); | ||
class ResumePayload extends gateway_payload_1.GatewayPayload { | ||
constructor(token, session_id, seq) { | ||
super(); | ||
this.op = 6; | ||
this.d = { | ||
token, | ||
session_id, | ||
seq | ||
}; | ||
return _this; | ||
} | ||
return ResumePayload; | ||
}(gateway_payload_1.GatewayPayload)); | ||
} | ||
exports.ResumePayload = ResumePayload; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
148505
146
3756
37
1