March 7th
2022-03-24 19:35:59 +07:00
parent 7dfdef46a5
commit a51d06c874
7 changed files with 115 additions and 40 deletions

View File

@@ -30,6 +30,22 @@ class ClientUser extends User {
}
if ('token' in data) this.client.token = data.token;
// Add (Selfbot)
if ('premium' in data) this.nitro = data.premium;
/**
* Nitro Status
* `0`: None
* `1`: Classic
* `2`: Boost
* @external
* https://discord.com/developers/docs/resources/user#user-object-premium-types
* @type {Number}
*/
if ('purchased_flags' in data) this.nitroType = data.purchased_flags;
if ('phone' in data) this.phoneNumber = data.phone;
if ('nsfw_allowed' in data) this.nsfwAllowed = data.nsfw_allowed;
if ('email' in data) this.emailAddress = data.email;
}
/**

View File

@@ -1,6 +1,7 @@
'use strict';
const BaseMessageComponent = require('./BaseMessageComponent');
const { Message } = require('./Message');
const { RangeError } = require('../errors');
const { MessageButtonStyles, MessageComponentTypes } = require('../util/Constants');
const Util = require('../util/Util');
@@ -160,6 +161,32 @@ class MessageButton extends BaseMessageComponent {
static resolveStyle(style) {
return typeof style === 'string' ? style : MessageButtonStyles[style];
}
// Patch Click
/**
* Click the button
* @param {Message} message Discord Message
* @returns true if the button is clicked
*/
async click(message) {
if (!message instanceof Message) throw new Error("[UNKNOWN_MESSAGE] Please pass a valid Message");
await message.client.api.interactions.post(
{
data: {
type: 3, // ?
guild_id: message.guild?.id ?? null, // In DMs
channel_id: message.channel.id,
message_id: message.id,
application_id: message.author.id,
session_id: message.client.session_id,
data: {
component_type: 2, // Button
custom_id: this.customId
},
}
}
)
return true;
}
}
module.exports = MessageButton;