Fix Message cannot Send
- Known Issue: Unable to send Embed
This commit is contained in:
parent
8e987355f0
commit
721d1216e0
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "discord.js-selfbot-v13",
|
||||
"version": "0.0.3",
|
||||
"version": "0.1.0",
|
||||
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
|
||||
"main": "./src/index.js",
|
||||
"types": "./typings/index.d.ts",
|
||||
@ -44,8 +44,11 @@
|
||||
"@sapphire/async-queue": "^1.3.0",
|
||||
"@sapphire/snowflake": "^3.2.0",
|
||||
"@types/ws": "^8.5.2",
|
||||
"axios": "^0.26.1",
|
||||
"discord-api-types": "^0.27.3",
|
||||
"discord.js": "^13.6.0",
|
||||
"form-data": "^4.0.0",
|
||||
"json-bigint": "^1.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash.snakecase": "^4.1.1",
|
||||
"node-fetch": "^3.2.2",
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { Buffer } = require('node:buffer');
|
||||
const { isJSONEncodable } = require('@discordjs/builders');
|
||||
const { BaseMessageComponent, MessageEmbed } = require('discord.js');
|
||||
const { MessageFlags } = require('discord-api-types/v9');
|
||||
const { RangeError } = require('../errors');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
@ -109,7 +109,6 @@ class MessagePayload {
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the body.
|
||||
* @returns {MessagePayload}
|
||||
@ -131,8 +130,8 @@ class MessagePayload {
|
||||
}
|
||||
}
|
||||
|
||||
const components = this.options.components?.map(c =>
|
||||
isJSONEncodable(c) ? c.toJSON() : this.target.client.options.jsonTransformer(c),
|
||||
const components = this.options.components?.map((c) =>
|
||||
BaseMessageComponent.create(c).toJSON(),
|
||||
);
|
||||
|
||||
let username;
|
||||
@ -196,18 +195,23 @@ class MessagePayload {
|
||||
content,
|
||||
tts,
|
||||
nonce,
|
||||
embeds: this.options.embeds?.map(embed =>
|
||||
isJSONEncodable(embed) ? embed.toJSON() : this.target.client.options.jsonTransformer(embed),
|
||||
embeds: this.options.embeds?.map((embed) =>
|
||||
new MessageEmbed(embed).toJSON(),
|
||||
),
|
||||
components,
|
||||
username,
|
||||
avatar_url: avatarURL,
|
||||
allowed_mentions:
|
||||
typeof content === 'undefined' && typeof message_reference === 'undefined' ? undefined : allowedMentions,
|
||||
typeof content === 'undefined' &&
|
||||
typeof message_reference === 'undefined'
|
||||
? undefined
|
||||
: allowedMentions,
|
||||
flags,
|
||||
message_reference,
|
||||
attachments: this.options.attachments,
|
||||
sticker_ids: this.options.stickers?.map(sticker => sticker.id ?? sticker),
|
||||
sticker_ids: this.options.stickers?.map(
|
||||
(sticker) => sticker.id ?? sticker,
|
||||
),
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
@ -7,7 +7,49 @@ const { TypeError, Error } = require('../../errors');
|
||||
const InteractionCollector = require('../InteractionCollector');
|
||||
const MessageCollector = require('../MessageCollector');
|
||||
const MessagePayload = require('../MessagePayload');
|
||||
const DiscordAPIError = require('../../rest/DiscordAPIError');
|
||||
|
||||
const _send = (client, channelID, data, files) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
require('axios')({
|
||||
method: 'post',
|
||||
url: `${client.options.http.api}/v${client.options.http.version}/channels/${channelID}/messages`,
|
||||
headers: {
|
||||
authorization: client.token,
|
||||
Accept: '*/*',
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://discord.com/channels/@me',
|
||||
'Sec-Ch-Ua': '" Not A;Brand";v="99" "',
|
||||
'Sec-Ch-Ua-Mobile': '?0',
|
||||
'Sec-Ch-Ua-Platform': '"iOS"',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'X-Debug-Options': 'bugReporterEnabled',
|
||||
'X-Discord-Locale': 'en-US',
|
||||
Origin: 'https://discord.com',
|
||||
},
|
||||
data,
|
||||
files,
|
||||
})
|
||||
.then((res) => resolve(res.data))
|
||||
.catch((err) => {
|
||||
err.request.options = {
|
||||
data,
|
||||
files,
|
||||
};
|
||||
return reject(
|
||||
new DiscordAPIError(
|
||||
err.response.data,
|
||||
err.response.status,
|
||||
err.request,
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Interface for classes that have text-channel-like features.
|
||||
* @interface
|
||||
@ -173,12 +215,15 @@ class TextBasedChannel {
|
||||
}
|
||||
|
||||
const { body, files } = await messagePayload.resolveFiles();
|
||||
const d = await this.client.api.channels[this.id].messages.post({ body, files });
|
||||
|
||||
console.log(body);
|
||||
// const d = await this.client.api.channels[this.id].messages.post({ body, files });
|
||||
const d = await _send(this.client, this.id, body, files);
|
||||
console.log(d);
|
||||
await this.client.api.channels(this.id).typing.delete();
|
||||
return this.messages.cache.get(d.id) ?? this.messages._add(d);
|
||||
}
|
||||
|
||||
// Patch send message [fck :(]
|
||||
/**
|
||||
* Sends a typing indicator in the channel.
|
||||
* @returns {Promise<void>} Resolves upon the typing status being sent
|
||||
@ -294,22 +339,35 @@ class TextBasedChannel {
|
||||
*/
|
||||
async bulkDelete(messages, filterOld = false) {
|
||||
if (Array.isArray(messages) || messages instanceof Collection) {
|
||||
let messageIds = messages instanceof Collection ? [...messages.keys()] : messages.map(m => m.id ?? m);
|
||||
let messageIds =
|
||||
messages instanceof Collection
|
||||
? [...messages.keys()]
|
||||
: messages.map((m) => m.id ?? m);
|
||||
if (filterOld) {
|
||||
messageIds = messageIds.filter(id => Date.now() - DiscordSnowflake.timestampFrom(id) < 1_209_600_000);
|
||||
messageIds = messageIds.filter(
|
||||
(id) =>
|
||||
Date.now() - DiscordSnowflake.timestampFrom(id) < 1_209_600_000,
|
||||
);
|
||||
}
|
||||
if (messageIds.length === 0) return new Collection();
|
||||
if (messageIds.length === 1) {
|
||||
await this.client.api.channels(this.id).messages(messageIds[0]).delete();
|
||||
await this.client.api
|
||||
.channels(this.id)
|
||||
.messages(messageIds[0])
|
||||
.delete();
|
||||
const message = this.client.actions.MessageDelete.getMessage(
|
||||
{
|
||||
message_id: messageIds[0],
|
||||
},
|
||||
this,
|
||||
);
|
||||
return message ? new Collection([[message.id, message]]) : new Collection();
|
||||
return message
|
||||
? new Collection([[message.id, message]])
|
||||
: new Collection();
|
||||
}
|
||||
await this.client.api.channels(this.id).messages['bulk-delete'].post({ body: { messages: messageIds } });
|
||||
await this.client.api
|
||||
.channels(this.id)
|
||||
.messages['bulk-delete'].post({ body: { messages: messageIds } });
|
||||
return messageIds.reduce(
|
||||
(col, id) =>
|
||||
col.set(
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
const process = require('node:process');
|
||||
const Transformers = require('./Transformers');
|
||||
const JSONBig = require('json-bigint');
|
||||
|
||||
/**
|
||||
* @typedef {Function} CacheFactory
|
||||
@ -101,21 +102,22 @@ class Options extends null {
|
||||
},
|
||||
http: {
|
||||
headers: {
|
||||
"Accept": "*/*",
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
"Accept-Language": 'en-US,en;q=0.9',
|
||||
"Cache-Control": "no-cache",
|
||||
"Pragma": "no-cache",
|
||||
"Referer": "https://discord.com/channels/@me",
|
||||
"Sec-Ch-Ua": '" Not A;Brand";v="99" "',
|
||||
"Sec-Ch-Ua-Mobile": '?0',
|
||||
"Sec-Ch-Ua-Platform": '"iOS"',
|
||||
"Sec-Fetch-Dest": "empty",
|
||||
"Sec-Fetch-Mode": "cors",
|
||||
"Sec-Fetch-Site": "same-origin",
|
||||
"X-Debug-Options": "bugReporterEnabled",
|
||||
"X-Discord-Locale": 'en-US',
|
||||
"Origin": "https://discord.com"
|
||||
Accept: '*/*',
|
||||
// 'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Content-Type': 'application/json',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://discord.com/channels/@me',
|
||||
'Sec-Ch-Ua': '" Not A;Brand";v="99" "',
|
||||
'Sec-Ch-Ua-Mobile': '?0',
|
||||
'Sec-Ch-Ua-Platform': '"iOS"',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'X-Debug-Options': 'bugReporterEnabled',
|
||||
'X-Discord-Locale': 'en-US',
|
||||
Origin: 'https://discord.com',
|
||||
},
|
||||
agent: {},
|
||||
version: 9,
|
||||
@ -125,6 +127,7 @@ class Options extends null {
|
||||
template: 'https://discord.new',
|
||||
scheduledEvent: 'https://discord.com/events',
|
||||
},
|
||||
jsonTransformer: (object) => JSONBig.stringify(object),
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user