chore(release): version

This commit is contained in:
Cinnamon 2022-06-26 13:40:26 +07:00
parent c097deeab4
commit 736238f3df
11 changed files with 78 additions and 29 deletions

File diff suppressed because one or more lines are too long

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "discord.js-selfbot-v13",
"version": "2.3.53",
"version": "2.3.6",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "discord.js-selfbot-v13",
"version": "2.3.53",
"version": "2.3.6",
"license": "GNU General Public License v3.0",
"dependencies": {
"@aikochan2k6/qrcode-terminal": "^0.12.0",

View File

@ -1,6 +1,6 @@
{
"name": "discord.js-selfbot-v13",
"version": "2.3.53",
"version": "2.3.6",
"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

@ -388,6 +388,20 @@ class Client extends BaseClient {
this.token = null;
}
/**
* Logs out, terminates the connection to Discord, destroys the client and destroys the token.
* @returns {Promise<void>}
*/
async logout() {
await this.api.auth.logout.post({
data: {
provider: null,
voip_provider: null,
},
});
this.destroy();
}
/**
* Options used when fetching an invite from Discord.
* @typedef {Object} ClientFetchInviteOptions

View File

@ -48,6 +48,7 @@ const Messages = {
EMBED_DESCRIPTION: 'MessageEmbed description must be a string.',
EMBED_AUTHOR_NAME: 'MessageEmbed author name must be a string.',
/* Add */
MISSING_PERMISSIONS: (...permission) => `You can't do this action [Missing Permission(s): ${permission.join(', ')}]`,
EMBED_PROVIDER_NAME: 'MessageEmbed provider name must be a string.',
BUTTON_LABEL: 'MessageButton label must be a string',

View File

@ -2,7 +2,6 @@
const Team = require('./Team');
const Application = require('./interfaces/Application');
const { Error } = require('../errors/DJSError');
const ApplicationCommandManager = require('../managers/ApplicationCommandManager');
const ApplicationFlags = require('../util/ApplicationFlags');
const Permissions = require('../util/Permissions');
@ -18,14 +17,14 @@ const Permissions = require('../util/Permissions');
* @extends {Application}
*/
class ClientApplication extends Application {
constructor(client, data) {
constructor(client, data, user) {
super(client, data);
/**
* The application command manager for this application
* @type {ApplicationCommandManager}
*/
this.commands = new ApplicationCommandManager(this.client);
this.commands = new ApplicationCommandManager(this.client, undefined, user);
}
_patch(data) {
@ -133,10 +132,14 @@ class ClientApplication extends Application {
* @returns {Promise<ClientApplication>}
*/
async fetch() {
// if (!this.client.user.bot) throw new Error('INVALID_USER_METHOD');
const app = await this.client.api.oauth2.applications(this.id).get();
console.log(app);
this._patch(app);
const app = await this.client.api.oauth2.authorize.get({
query: {
client_id: this.id,
scope: 'bot',
},
});
this.client.users._add(app.bot);
this._patch(app.application);
return this;
}
}

View File

@ -659,7 +659,7 @@ class Guild extends AnonymousGuild {
resolve(
this.client.users.cache
.get(botId)
?.applications?.cache?.find(
?.application?.commands?.cache?.find(
c => (c.name === query && c.type == type) || c.type == ApplicationCommandTypes[type],
),
);
@ -1510,6 +1510,37 @@ class Guild extends AnonymousGuild {
}
}
/**
* Add Integrations to the guild
* @param {Snowflake} applicationId Application (ID) target
* @returns {Promise<void>}
*/
async addIntegration(applicationId) {
if (!this.me.permissions.has('MANAGE_WEBHOOKS')) {
throw new Error('MISSING_PERMISSIONS', 'MANAGE_WEBHOOKS');
}
if (!this.me.permissions.has('MANAGE_GUILD')) {
throw new Error('MISSING_PERMISSIONS', 'MANAGE_GUILD');
}
if (!applicationId || typeof applicationId !== 'string') throw new TypeError('INVALID_APPLICATION_ID');
// Check permission
await this.client.api.oauth2.authorize.post({
query: {
client_id: applicationId,
scope: 'applications.commands',
},
data: {
guild_id: this.id,
permissions: '0',
authorize: true,
},
});
}
addBot() {
console.log('Test only (Addbot)');
}
toJSON() {
const json = super.toJSON({
available: false,

View File

@ -1081,7 +1081,7 @@ class Message extends Base {
async contextMenu(botId, commandName) {
if (!botId) throw new Error('Bot ID is required');
const user = await this.client.users.fetch(botId).catch(() => {});
if (!user || !user.bot || !user.applications) {
if (!user || !user.bot || !user.application) {
throw new Error('BotID is not a bot or does not have an application slash command');
}
if (!commandName || typeof commandName !== 'string') {

View File

@ -94,7 +94,8 @@ class User extends Base {
*/
this.bot = Boolean(data.bot);
if (this.bot === true) {
this.application = new ClientApplication(this.client, { id: this.id });
this.application = new ClientApplication(this.client, { id: this.id }, this);
this.botInGuildsCount = null;
}
} else if (!this.partial && typeof this.bot !== 'boolean') {
this.bot = false;
@ -159,6 +160,14 @@ class User extends Base {
*/
this.flags = new UserFlags(data.public_flags);
}
if ('approximate_guild_count' in data) {
/**
* Check how many guilds the bot is in (Probably only approximate) (application.fetch() first)
* @type {?number}
*/
this.botInGuildsCount = data.approximate_guild_count;
}
}
/**
@ -487,18 +496,6 @@ class User extends Base {
return data;
}
async fetchBotInfo() {
if (this.client.user.bot) throw new Error('INVALID_BOT_METHOD');
if (!this.bot) throw new Error('BOT_ONLY');
const result = await this.client.api.oauth2.authorize.get({
query: {
client_id: this.id,
scope: 'bot',
},
});
console.log(result);
}
// These are here only for documentation purposes - they are implemented by TextBasedChannel
/* eslint-disable no-empty-function */
send() {}

View File

@ -402,7 +402,7 @@ class TextBasedChannel {
if (!botId) throw new Error('Bot ID is required');
// ? maybe ...
const user = await this.client.users.fetch(botId).catch(() => {});
if (!user || !user.bot || !user.applications) {
if (!user || !user.bot || !user.application) {
throw new Error('botId is not a bot or does not have an application slash command');
}
if (!commandName || typeof commandName !== 'string') throw new Error('Command name is required');
@ -425,7 +425,7 @@ class TextBasedChannel {
if (command.name == commandName) commandTarget = c;
} else {
const tempUser = this.client.users.cache.get(command.application_id);
if (tempUser && tempUser.bot && tempUser.applications) {
if (tempUser && tempUser.bot && tempUser.application) {
tempUser.application?.commands?._add(command, true);
}
}

5
typings/index.d.ts vendored
View File

@ -618,6 +618,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
public ws: WebSocketManager;
public password: string | null;
public destroy(): void;
public logout(): Promise<void>;
public fetchGuildPreview(guild: GuildResolvable): Promise<GuildPreview>;
public fetchInvite(invite: InviteResolvable, options?: ClientFetchInviteOptions): Promise<Invite>;
public fetchGuildTemplate(template: GuildTemplateResolvable): Promise<GuildTemplate>;
@ -1140,6 +1141,7 @@ export class GuildAuditLogsEntry<
: Role | GuildEmoji | { id: Snowflake } | null;
public targetType: TTargetType;
public toJSON(): unknown;
public addIntegration(applicationId: Snowflake): Promise<void>;
}
export class GuildBan extends Base {
@ -2681,7 +2683,7 @@ export class Typing extends Base {
export class User extends PartialTextBasedChannel(Base) {
protected constructor(client: Client, data: RawUserData);
private _equals(user: APIUser): boolean;
public applications: ApplicationCommandManager;
public application: ClientApplication;
public accentColor: number | null | undefined;
public avatar: string | null;
public banner: string | null | undefined;
@ -2693,6 +2695,7 @@ export class User extends PartialTextBasedChannel(Base) {
public readonly defaultAvatarURL: string;
public readonly dmChannel: DMChannel | null;
public flags: Readonly<UserFlags> | null;
public botInGuildsCount: number | null | undefined;
public readonly hexAccentColor: HexColorString | null | undefined;
public id: Snowflake;
public readonly partial: false;