Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snowtransfer

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snowtransfer - npm Package Compare versions

Comparing version 0.5.5 to 0.5.6

4

dist/methods/Channels.d.ts

@@ -540,3 +540,3 @@ /// <reference types="node" />

reason?: string;
}): Promise<import("discord-typings").NewsThread | import("discord-typings").PublicThread>;
}): Promise<import("discord-typings").AnnouncementThread | import("discord-typings").PublicThread>;
/**

@@ -683,3 +683,3 @@ * Creates a thread under a guild channel without a message

}): Promise<{
threads: Array<import("discord-typings").NewsThread | import("discord-typings").PublicThread>;
threads: Array<import("discord-typings").AnnouncementThread | import("discord-typings").PublicThread>;
members: Array<import("discord-typings").ThreadMember>;

@@ -686,0 +686,0 @@ has_more: boolean;

@@ -7,2 +7,3 @@ "use strict";

const Constants_1 = __importDefault(require("../Constants"));
const mentionRegex = /@([^<>@ ]*)/gsmu;
/**

@@ -170,3 +171,3 @@ * Methods for interacting with Channels and Messages

if (data.content && (options.disableEveryone !== undefined ? options.disableEveryone : this.disableEveryone))
data.content = data.content.replace(/@([^<>@ ]*)/gsmu, replaceEveryone);
data.content = data.content.replace(mentionRegex, replaceEveryone);
if (data.files)

@@ -346,3 +347,3 @@ return this.requestHandler.request(Endpoints_1.default.CHANNEL_MESSAGES(channelId), "post", "multipart", data);

if (data.content && (options.disableEveryone !== undefined ? options.disableEveryone : this.disableEveryone))
data.content = data.content.replace(/@([^<>@ ]*)/gsmu, replaceEveryone);
data.content = data.content.replace(mentionRegex, replaceEveryone);
if (data.files)

@@ -764,4 +765,5 @@ return this.requestHandler.request(Endpoints_1.default.CHANNEL_MESSAGE(channelId, messageId), "patch", "multipart", data);

ChannelMethods.default = ChannelMethods;
const isValidUserMentionRegex = /^[&!]?\d+$/;
function replaceEveryone(_match, target) {
if (target.match(/^[&!]?\d+$/))
if (isValidUserMentionRegex.test(target))
return `@${target}`;

@@ -768,0 +770,0 @@ else

@@ -6,2 +6,3 @@ "use strict";

const Endpoints_1 = __importDefault(require("../Endpoints"));
const mentionRegex = /@([^<>@ ]*)/gsmu;
/**

@@ -131,3 +132,3 @@ * Methods for handling webhook interactions

if (data.content && ((options === null || options === void 0 ? void 0 : options.disableEveryone) !== undefined ? options.disableEveryone : this.disableEveryone))
data.content = data.content.replace(/@([^<>@ ]*)/gsmu, replaceEveryone);
data.content = data.content.replace(mentionRegex, replaceEveryone);
if (options) {

@@ -155,3 +156,3 @@ delete options.disableEveryone;

if (data.text && ((options === null || options === void 0 ? void 0 : options.disableEveryone) !== undefined ? options.disableEveryone : this.disableEveryone))
data.text = data.text.replace(/@([^<>@ ]*)/gsmu, replaceEveryone);
data.text = data.text.replace(mentionRegex, replaceEveryone);
if (options) {

@@ -218,4 +219,5 @@ delete options.disableEveryone;

WebhookMethods.default = WebhookMethods;
const isValidUserMentionRegex = /^[&!]?\d+$/;
function replaceEveryone(_match, target) {
if (target.match(/^[&!]?\d+$/))
if (isValidUserMentionRegex.test(target))
return `@${target}`;

@@ -222,0 +224,0 @@ else

@@ -6,2 +6,7 @@ "use strict";

const LocalBucket_1 = __importDefault(require("./LocalBucket"));
const routeRegex = /\/([a-z-]+)\/(?:[0-9]+)/g;
const reactionsRegex = /\/reactions\/[^/]+/g;
const reactionsUserRegex = /\/reactions\/:id\/[^/]+/g;
const webhooksRegex = /^\/webhooks\/(\d+)\/[A-Za-z0-9-_]+/;
const isMessageEndpointRegex = /\/messages\/:id$/;
/**

@@ -68,6 +73,6 @@ * Ratelimiter used for handling the ratelimits imposed by the rest api

routify(url, method) {
let route = url.replace(/\/([a-z-]+)\/(?:\d+)/g, function (match, p) {
let route = url.replace(routeRegex, function (match, p) {
return p === "channels" || p === "guilds" || p === "webhooks" ? match : `/${p}/:id`;
}).replace(/\/reactions\/[^/]+/g, "/reactions/:id").replace(/^\/webhooks\/(\d+)\/[A-Za-z0-9-_]{64,}/, "/webhooks/$1/:token");
if (method.toUpperCase() === "DELETE" && route.endsWith("/messages/:id"))
}).replace(reactionsRegex, "/reactions/:id").replace(reactionsUserRegex, "/reactions/:id/:userID").replace(webhooksRegex, "/webhooks/$1/:token");
if (method.toUpperCase() === "DELETE" && isMessageEndpointRegex.test(route))
route = method + route; // Delete Messsage endpoint has its own ratelimit

@@ -74,0 +79,0 @@ return route;

@@ -14,2 +14,5 @@ "use strict";

const Constants_1 = __importDefault(require("./Constants"));
const includesSlashBansRegex = /\/bans/;
const includesSlashPruneRegex = /\/prune/;
const applicationJSONRegex = /application\/json/;
class DiscordAPIError extends Error {

@@ -65,3 +68,2 @@ constructor(path, error, method, status) {

this.ratelimiter.queue(async (bkt) => {
var _a;
const reqID = crypto_1.default.randomBytes(20).toString("hex");

@@ -72,3 +74,3 @@ try {

if (dataType == "json")
request = await this._request(endpoint, method, data, (method === "get" || endpoint.includes("/bans") || endpoint.includes("/prune")));
request = await this._request(endpoint, method, data, (method === "get" || includesSlashBansRegex.test(endpoint) || includesSlashPruneRegex.test(endpoint)));
else if (dataType == "multipart")

@@ -79,3 +81,3 @@ request = await this._multiPartRequest(endpoint, method, data);

if (request.statusCode && !Constants_1.default.OK_STATUS_CODES.includes(request.statusCode) && request.statusCode !== 429)
throw new DiscordAPIError(endpoint, ((_a = request.headers["content-type"]) === null || _a === void 0 ? void 0 : _a.startsWith("application/json")) ? await request.json() : request.body.toString(), method, request.statusCode);
throw new DiscordAPIError(endpoint, request.headers["content-type"] && applicationJSONRegex.test(request.headers["content-type"]) ? await request.json() : request.body.toString(), method, request.statusCode);
this._applyRatelimitHeaders(bkt, request.headers);

@@ -82,0 +84,0 @@ if (request.statusCode === 429) {

{
"name": "snowtransfer",
"version": "0.5.5",
"version": "0.5.6",
"description": "Minimalistic Rest client for the Discord Api",

@@ -33,3 +33,3 @@ "main": "./dist/index.js",

"centra": "^2.5.0",
"discord-typings": "^10.3.0",
"discord-typings": "^10.4.1",
"form-data": "~4.0.0"

@@ -39,10 +39,10 @@ },

"@types/centra": "^2.2.0",
"@types/node": "^18.6.5",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"eslint": "^8.21.0",
"typedoc": "^0.23.10",
"@types/node": "^18.8.5",
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"eslint": "^8.25.0",
"typedoc": "^0.23.16",
"typedoc-plugin-mdn-links": "^2.0.0",
"typedoc-plugin-missing-exports": "^0.23.0",
"typescript": "^4.7.4"
"typedoc-plugin-missing-exports": "^1.0.0",
"typescript": "^4.8.4"
},

@@ -49,0 +49,0 @@ "files": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc