feat: Using new attachment API
This commit is contained in:
@@ -42,6 +42,7 @@ const { randomUA } = require('../util/Constants');
|
||||
* @property {string} [captchaService=null] Captcha service to use for solving captcha {@link captchaServices}
|
||||
* @property {string} [captchaKey=null] Captcha service key
|
||||
* @property {string} [password=null] Your Discord account password
|
||||
* @property {boolean} [usingNewAttachmentAPI=true] Use new attachment API
|
||||
* @property {string} [interactionTimeout=15000] The amount of time in milliseconds to wait for an interaction response, before rejecting
|
||||
* @property {boolean} [autoRedeemNitro=false] Automaticlly redeems nitro codes <NOTE: there is no cooldown on the auto redeem>
|
||||
* @property {string} [proxy] Proxy to use for the WebSocket + REST connection (proxy-agent uri type) {@link https://www.npmjs.com/package/proxy-agent}.
|
||||
@@ -157,6 +158,7 @@ class Options extends null {
|
||||
DMSync: false,
|
||||
patchVoice: false,
|
||||
password: null,
|
||||
usingNewAttachmentAPI: true,
|
||||
interactionTimeout: 15_000,
|
||||
waitGuildTimeout: 15_000,
|
||||
messageCreateEventGuildTimeout: 100,
|
||||
|
@@ -3,6 +3,7 @@
|
||||
const { parse } = require('node:path');
|
||||
const process = require('node:process');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const axios = require('axios');
|
||||
const fetch = require('node-fetch');
|
||||
const { Colors, Endpoints } = require('./Constants');
|
||||
const Options = require('./Options');
|
||||
@@ -728,6 +729,25 @@ class Util extends null {
|
||||
emoji_name: defaultReaction.name,
|
||||
};
|
||||
}
|
||||
|
||||
static async getAttachments(client, channelId, ...files) {
|
||||
files = files.flat(2).map((file, i) => ({
|
||||
filename: file.name ?? file.attachment?.name ?? file.attachment?.filename ?? 'file.jpg',
|
||||
// 8MB = 8388608 bytes
|
||||
file_size: Math.floor((8_388_608 / 10) * Math.random()),
|
||||
id: `${i}`,
|
||||
}));
|
||||
const { attachments } = await client.api.channels[channelId].attachments.post({
|
||||
data: {
|
||||
files,
|
||||
},
|
||||
});
|
||||
return attachments;
|
||||
}
|
||||
|
||||
static uploadFile(data, url) {
|
||||
return axios.put(url, data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;
|
||||
|
Reference in New Issue
Block a user