feat: update (see description)
- Remove `bignumber.js` - Fix `circular dependency` - Fix: missing activity.name (SpotifyRPC) - Refactor code - Update UserAgent
This commit is contained in:
@@ -257,10 +257,6 @@ class DMChannel extends Channel {
|
||||
this.client.voice.adapters.set(this.id, methods);
|
||||
return {
|
||||
sendPayload: data => {
|
||||
data.d = {
|
||||
...data.d,
|
||||
self_video: false,
|
||||
};
|
||||
if (this.shard.status !== Status.READY) return false;
|
||||
this.shard.send(data);
|
||||
return true;
|
||||
|
||||
@@ -1471,9 +1471,9 @@ class Guild extends AnonymousGuild {
|
||||
/**
|
||||
* Add Integrations to the guild.
|
||||
* @param {Snowflake} applicationId Application (ID) target
|
||||
* @returns {Promise<void>}
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async addIntegration(applicationId) {
|
||||
addIntegration(applicationId) {
|
||||
if (!this.me.permissions.has('MANAGE_WEBHOOKS')) {
|
||||
throw new Error('MISSING_PERMISSIONS', 'MANAGE_WEBHOOKS');
|
||||
}
|
||||
@@ -1481,18 +1481,14 @@ class Guild extends AnonymousGuild {
|
||||
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: {
|
||||
return this.client.authorizeURL(
|
||||
`https://discord.com/api/oauth2/authorize?client_id=${applicationId}&scope=applications.commands`,
|
||||
{
|
||||
guild_id: this.id,
|
||||
permissions: '0',
|
||||
permissions: `0`,
|
||||
authorize: true,
|
||||
},
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1501,7 +1497,7 @@ class Guild extends AnonymousGuild {
|
||||
* @param {?PermissionResolvable} permissions Permissions
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
addBot(bot, permissions) {
|
||||
addBot(bot, permissions = 0n) {
|
||||
if (!this.me.permissions.has('MANAGE_WEBHOOKS')) {
|
||||
throw new Error('MISSING_PERMISSIONS', 'MANAGE_WEBHOOKS');
|
||||
}
|
||||
@@ -1514,8 +1510,8 @@ class Guild extends AnonymousGuild {
|
||||
if (!botId) throw new TypeError('INVALID_BOT_ID');
|
||||
// Check permission
|
||||
const selfPerm = this.me.permissions.toArray();
|
||||
const missingPerms = permission.toArray().filter(x => selfPerm.indexOf(x) === -1);
|
||||
if (missingPerms[0]) {
|
||||
const missingPerms = permission.toArray().filter(x => selfPerm.includes(x));
|
||||
if (missingPerms.length) {
|
||||
throw new Error('MISSING_PERMISSIONS', missingPerms.join(', '));
|
||||
}
|
||||
// Add bot
|
||||
|
||||
@@ -321,7 +321,7 @@ class Invite extends Base {
|
||||
/**
|
||||
* Join this Guild using this invite.
|
||||
* @param {boolean} autoVerify Whether to automatically verify member
|
||||
* @returns {Promise<void>}
|
||||
* @returns {Promise<Guild>}
|
||||
* @example
|
||||
* await client.fetchInvite('code').then(async invite => {
|
||||
* await invite.acceptInvite();
|
||||
@@ -329,6 +329,7 @@ class Invite extends Base {
|
||||
*/
|
||||
async acceptInvite(autoVerify = true) {
|
||||
if (!this.guild) throw new Error('INVITE_NO_GUILD');
|
||||
if (this.client.guilds.cache.get(this.guild.id)) return this.guild;
|
||||
const dataHeader = {
|
||||
location: 'Join Guild',
|
||||
location_guild_id: this.guild?.id,
|
||||
@@ -341,18 +342,19 @@ class Invite extends Base {
|
||||
'X-Context-Properties': Buffer.from(JSON.stringify(dataHeader), 'utf8').toString('base64'),
|
||||
},
|
||||
});
|
||||
const guild = this.client.guilds.cache.get(this.guild.id);
|
||||
if (autoVerify) {
|
||||
const getForm = await this.client.api
|
||||
.guilds(this.guild.id)
|
||||
['member-verification'].get({ query: { with_guild: false, invite_code: this.code } })
|
||||
.catch(() => {});
|
||||
if (!getForm) return undefined;
|
||||
if (!getForm) return guild;
|
||||
const form = Object.assign(getForm.form_fields[0], { response: true });
|
||||
// Respond to the form
|
||||
// https://discord.com/api/v9/guilds/:id/requests/@me
|
||||
await this.client.api.guilds(this.guild.id).requests['@me'].put({ data: { form_fields: [form] } });
|
||||
}
|
||||
return undefined;
|
||||
return guild;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
const { setTimeout } = require('node:timers');
|
||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const { Message } = require('./Message');
|
||||
const { MessageComponentTypes, InteractionTypes, ChannelTypes } = require('../util/Constants');
|
||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
const Util = require('../util/Util');
|
||||
const { lazy } = require('../util/Util');
|
||||
const Message = lazy(() => require('./Message').Message);
|
||||
|
||||
/**
|
||||
* Represents a select menu message component
|
||||
@@ -284,7 +285,7 @@ class MessageSelectMenu extends BaseMessageComponent {
|
||||
* @returns {Promise<InteractionResponse>}
|
||||
*/
|
||||
async select(message, values = []) {
|
||||
if (!(message instanceof Message)) throw new Error('[UNKNOWN_MESSAGE] Please pass a valid Message');
|
||||
if (!(message instanceof Message())) throw new Error('[UNKNOWN_MESSAGE] Please pass a valid Message');
|
||||
if (!Array.isArray(values)) throw new TypeError('[INVALID_VALUES] Please pass an array of values');
|
||||
if (!this.customId || this.disabled) return false; // Disabled or null customID
|
||||
// Check value is invalid [Max options is 20] => For loop
|
||||
|
||||
@@ -407,10 +407,6 @@ class PartialGroupDMChannel extends Channel {
|
||||
this.client.voice.adapters.set(this.id, methods);
|
||||
return {
|
||||
sendPayload: data => {
|
||||
data.d = {
|
||||
...data.d,
|
||||
self_video: false,
|
||||
};
|
||||
if (this.shard.status !== Status.READY) return false;
|
||||
this.shard.send(data);
|
||||
return true;
|
||||
|
||||
@@ -294,7 +294,7 @@ https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichP
|
||||
* @returns {RichPresence}
|
||||
*/
|
||||
setType(type) {
|
||||
this.type = ActivityTypes[type?.toUpperCase()];
|
||||
this.type = ActivityTypes[type];
|
||||
if (typeof this.type == 'string') this.type = ActivityTypes[this.type];
|
||||
if (typeof this.type != 'number') throw new Error('Type must be a valid ActivityType');
|
||||
return this;
|
||||
@@ -471,11 +471,9 @@ https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Documents/RichP
|
||||
delete obj.name;
|
||||
delete obj.url;
|
||||
obj.type = 0;
|
||||
let buttonData = [];
|
||||
if (obj.buttons) {
|
||||
buttonData = obj.buttons.map((b, i) => ({ label: b, url: obj.metadata.button_urls[i] }));
|
||||
if (obj.buttons?.length) {
|
||||
obj.buttons = obj.buttons.map((b, i) => ({ label: b, url: obj.metadata.button_urls[i] }));
|
||||
delete obj.metadata;
|
||||
obj.buttons = buttonData;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
@@ -566,6 +564,10 @@ class SpotifyRPC extends RichPresence {
|
||||
* @private
|
||||
*/
|
||||
setup(options) {
|
||||
this.name = options.name || 'Spotify';
|
||||
|
||||
this.type = ActivityTypes.LISTENING;
|
||||
|
||||
this.party = {
|
||||
id: `spotify:${this.client.user.id}`,
|
||||
};
|
||||
@@ -638,8 +640,8 @@ class SpotifyRPC extends RichPresence {
|
||||
toJSON() {
|
||||
if (!this.sync_id) throw new Error('Song id is required');
|
||||
const obj = {
|
||||
name: 'Spotify',
|
||||
type: ActivityTypes.LISTENING,
|
||||
name: this.name,
|
||||
type: this.type,
|
||||
application_id: this.application_id,
|
||||
url: this.url,
|
||||
state: this.state,
|
||||
|
||||
Reference in New Issue
Block a user