feat: <Message>.markUnread() #65

and script check update module .-.
This commit is contained in:
March 7th 2022-04-29 12:35:28 +07:00
parent c7cc764718
commit 615c772280
5 changed files with 3970 additions and 370 deletions

4220
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "discord.js-selfbot-v13",
"version": "1.3.93",
"version": "1.3.94",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js",
"types": "./typings/index.d.ts",
@ -11,7 +11,8 @@
"lint:typings": "tslint typings/index.d.ts",
"lint:typings:fix": "tslint typings/index.d.ts --fix",
"format": "prettier --write src/**/*.js typings/**/*.ts",
"lint:all": "npm run lint && npm run lint:typings"
"lint:all": "npm run lint && npm run lint:typings",
"checkup": "node update.mjs"
},
"files": [
"src",
@ -47,25 +48,28 @@
"dependencies": {
"@discordjs/builders": "^0.13.0",
"@discordjs/collection": "^0.6.0",
"@sapphire/async-queue": "^1.3.0",
"@sapphire/snowflake": "^3.2.0",
"@types/node-fetch": "^2.5.12",
"@types/ws": "^8.5.2",
"axios": "^0.27.1",
"@sapphire/async-queue": "^1.3.1",
"@sapphire/snowflake": "^3.2.2",
"@types/node-fetch": "^2.6.1",
"@types/ws": "^8.5.3",
"ascii-table": "^0.0.9",
"axios": "^0.27.2",
"bignumber.js": "^9.0.2",
"bufferutil": "^4.0.6",
"chalk": "^4.1.2",
"discord-api-types": "^0.32.0",
"discord-bettermarkdown": "^1.1.0",
"discord-rpc-contructor": "^1.1.1",
"discord-rpc-contructor": "^1.1.5",
"discord.js": "^13.6.0",
"form-data": "^4.0.0",
"i": "^0.3.7",
"json-bigint": "^1.0.0",
"lodash": "^4.17.21",
"lodash.snakecase": "^4.1.1",
"node-fetch": "^2.6.1",
"npm": "^8.8.0",
"string-similarity": "^4.0.4",
"undici": "^4.15.0",
"undici": "^4.16.0",
"utf-8-validate": "^5.0.9",
"ws": "^8.5.0"
},

View File

@ -992,6 +992,26 @@ class Message extends Base {
});
}
// Added
/**
* Marks the message as unread.
* @returns {boolean}
*/
async markUnread() {
await this.client.api.channels[this.channelId].messages[this.id].ack({
usingApplicationJson: true,
data: {
manual: true,
mention_count:
this.mentions.everyone ||
this.mentions.repliedUser?.id === this.client.user.id ||
this.mentions.users.has(this.client.user.id) ||
(this.guildId && this.mentions.roles.some(r => this.guild.me._roles?.includes(r.id)))
? 1
: 0,
},
});
return true;
}
/**
* Click specific button [Suggestion: Dux#2925]
* @param {string<Button.customId>} buttonID Button ID

1
typings/index.d.ts vendored
View File

@ -1606,6 +1606,7 @@ export class Message<Cached extends boolean = boolean> extends Base {
public unpin(): Promise<Message>;
public inGuild(): this is Message<true> & this;
// Added
public markUnread(): Promise<boolean>;
public clickButton(buttonID: String<MessageButton.customId>): Promise<pending>;
public selectMenu(menuID: String<MessageSelectMenu.customId> | options[], options: string[]): Promise<pending>;
public contextMenu(botID: DiscordBotID, commandName: String<ApplicationCommand.name>): Promise;

77
update.mjs Normal file
View File

@ -0,0 +1,77 @@
import axios from 'axios';
import chalk from 'chalk';
import ascii from 'ascii-table';
import path from 'path';
import { createRequire } from "module";
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const require = createRequire(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const table = new ascii('NPM Check Update by Shiraori#1782');
table.setHeading("Modules", "Current", chalk.whiteBright("Lastest"));
let cmd1 = '';
let cmd2 = '';
let cmd3 = '';
const func = async (package_ , current , array_ , start) => {
current = current.replace("^", "");
if(current.split(".").length == 1) current += ".0.0";
if(current.split(".").length == 2) current += ".0";
const array = []
try {
const res_ = await axios.get(`https://registry.npmjs.com/${encodeURIComponent(package_)}`);
const lastest_tag = res_.data['dist-tags'].latest;
// Checking if the package is outdated
if (current !== lastest_tag) {
const current_ = current.split('.');
const lastest_ = lastest_tag.split('.');
if (current_[0] !== lastest_[0]) {
array.push(`${package_}`);
array.push(`^${current}`);
array.push(`^${chalk.redBright(lastest_tag)}`);
cmd1 += `${package_}@${lastest_tag} `;
} else if (current_[1] !== lastest_[1]) {
array.push(`${package_}`);
array.push(`^${current}`);
array.push(`^${lastest_[0]}.${chalk.blueBright(`${lastest_[1]}.${lastest_[2]}`)}`);
cmd2 += `${package_}@${lastest_tag} `;
} else if (current_[2] !== lastest_[2]) {
array.push(`${package_}`);
array.push(`^${current}`);
array.push(`^${lastest_[0]}.${lastest_[1]}.${chalk.greenBright(lastest_[2])}`);
cmd3 += `${package_}@${lastest_tag} `;
}
}
return array[0] ? array : false;
} catch (e) {
console.log(e.message);
return false
}
}
try {
let start = 1;
let time = Date.now();
const { dependencies } = require('./package.json');
(async () => {
const array = Object.entries(dependencies);
console.log(`Checking ${path.join(__dirname, 'package.json')}, ${array.length} modules`);
await Promise.all(array.map(async arr => {
const result = await func(arr[0] , arr[1] , array , start);
start++;
if(result) table.addRow(result[0].replace(/\n/g, ""), result[1].replace(/\n/g, ""), result[2].replace(/\n/g, ""));
return 0;
}))
console.log(`Checking Success with ${(Date.now() - time) / 1000}s\n`);
if(cmd1 == cmd2 && cmd2 == cmd3 && cmd3 == '') {
console.log(chalk.greenBright(`All modules are up to date`));
} else {
console.log(table.toString());
console.log('You should update the following modules:');
if(cmd1 !== '') console.log(chalk.redBright(`npm i ${cmd1}`));
if(cmd2 !== '') console.log(chalk.blueBright(`npm i ${cmd2}`));
if(cmd3 !== '') console.log(chalk.greenBright(`npm i ${cmd3}`));
}
})()
} catch {
console.error('package.json not found');
}