Fix MessageEdit

Know: Webhook Edit error
This commit is contained in:
March 7th 2022-03-21 12:16:46 +07:00
parent 33c82f4e81
commit f5d2469842
3 changed files with 47 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "discord.js-selfbot-v13",
"version": "0.1.4",
"version": "0.1.5",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js",
"types": "./typings/index.d.ts",

View File

@ -7,6 +7,50 @@ const { TypeError } = require('../errors');
const { Message } = require('../structures/Message');
const MessagePayload = require('../structures/MessagePayload');
const Util = require('../util/Util');
const DiscordAPIError = require('../rest/DiscordAPIError');
const _edit = (client, channelID, messageID, data, files) => {
return new Promise((resolve, reject) => {
require('axios')({
method: 'patch',
url: `${client.options.http.api}/v${client.options.http.version}/channels/${channelID}/messages/${messageID}`,
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,
),
);
});
});
};
/**
* Manages API methods for Messages and holds their cache.
@ -130,8 +174,8 @@ class MessageManager extends CachedManager {
)
.resolveBody()
.resolveFiles();
const d = await this.client.api.channels(this.channel.id).messages(messageId).patch({ body, files });
// const d = await this.client.api.channels(this.channel.id).messages(messageId).patch({ body, files });
const d = await _edit(this.client, this.channel.id, messageId, body, files);
const existing = this.cache.get(messageId);
if (existing) {
const clone = existing._clone();

View File

@ -215,7 +215,6 @@ class TextBasedChannel {
}
const { body, files } = await messagePayload.resolveFiles();
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);
return this.messages.cache.get(d.id) ?? this.messages._add(d);