MessageSelectMenu select :)
This commit is contained in:
parent
b0b3f8579c
commit
9a1a43a5ce
@ -236,6 +236,14 @@ And you can change the status 5 times every 20 seconds!
|
|||||||
await Button.click(Message);
|
await Button.click(Message);
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
<details>
|
||||||
|
<summary>Message Select Menu (v1)</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
await MessageSelectMenu.select(Message, value);
|
||||||
|
// value: ['value1', 'value2' , ...]
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
## More features
|
## More features
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ window.webpackChunkdiscord_app.push([[Math.random()], {}, (req) => {for (const m
|
|||||||
- Get Profile GuildMember [Nitro Time, Boost Time, Connected Account, Bio, ...]
|
- Get Profile GuildMember [Nitro Time, Boost Time, Connected Account, Bio, ...]
|
||||||
- Setting Position Guild and Folder
|
- Setting Position Guild and Folder
|
||||||
- Custom Status and RPC (without button, because it's not working)
|
- Custom Status and RPC (without button, because it's not working)
|
||||||
|
- Interaction [Button, MessageSelectMenu, ...]
|
||||||
- You can request more features for my module by placing an issue!
|
- You can request more features for my module by placing an issue!
|
||||||
|
|
||||||
## Links [Discord.js]
|
## Links [Discord.js]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord.js-selfbot-v13",
|
"name": "discord.js-selfbot-v13",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
|
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
|
||||||
"main": "./src/index.js",
|
"main": "./src/index.js",
|
||||||
"types": "./typings/index.d.ts",
|
"types": "./typings/index.d.ts",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||||
const { MessageComponentTypes } = require('../util/Constants');
|
const { MessageComponentTypes } = require('../util/Constants');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
const { Message } = require('./Message');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a select menu message component
|
* Represents a select menu message component
|
||||||
@ -207,6 +208,43 @@ class MessageSelectMenu extends BaseMessageComponent {
|
|||||||
static normalizeOptions(...options) {
|
static normalizeOptions(...options) {
|
||||||
return options.flat(Infinity).map(option => this.normalizeOption(option));
|
return options.flat(Infinity).map(option => this.normalizeOption(option));
|
||||||
}
|
}
|
||||||
|
// Add
|
||||||
|
async select(message, values = []) {
|
||||||
|
// Github copilot is the best :))
|
||||||
|
// POST data from https://github.com/phamleduy04
|
||||||
|
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 || values.length == 0) return false; // Disabled or null customID or [] array
|
||||||
|
// Check value is invalid [Max options is 20] => For loop
|
||||||
|
if (values.length < this.minValues) throw new RangeError("[SELECT_MENU_MIN_VALUES] The minimum number of values is " + this.minValues);
|
||||||
|
if (values.length > this.maxValues) throw new RangeError("[SELECT_MENU_MAX_VALUES] The maximum number of values is " + this.maxValues);
|
||||||
|
const validValue = this.options.map(obj => obj.value);
|
||||||
|
const check_ = await values.find(element => {
|
||||||
|
if (typeof element !== 'string') return true;
|
||||||
|
if (!validValue.includes(element)) return true;
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
if (check_) throw new RangeError("[SELECT_MENU_INVALID_VALUE] The value " + check_ + " is invalid. Please use a valid value " + validValue.join(', '));
|
||||||
|
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: 3, // Select Menu
|
||||||
|
custom_id: this.customId,
|
||||||
|
type: 3, // Select Menu
|
||||||
|
values,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MessageSelectMenu;
|
module.exports = MessageSelectMenu;
|
||||||
|
Loading…
Reference in New Issue
Block a user