mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix: add static method from in builders (#7990)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { ActionRowBuilder: BuildersActionRow, ComponentBuilder } = require('@discordjs/builders');
|
||||
const { ActionRowBuilder: BuildersActionRow, ComponentBuilder, isJSONEncodable } = require('@discordjs/builders');
|
||||
const Components = require('../util/Components');
|
||||
const Transformers = require('../util/Transformers');
|
||||
|
||||
@@ -15,6 +15,19 @@ class ActionRowBuilder extends BuildersActionRow {
|
||||
components: components?.map(c => (c instanceof ComponentBuilder ? c : Components.createComponentBuilder(c))),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new action row builder from JSON data
|
||||
* @param {JSONEncodable<APIActionRowComponent<APIActionRowComponentTypes>>
|
||||
* |APIActionRowComponent<APIActionRowComponentTypes>} other The other data
|
||||
* @returns {ActionRowBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
if (isJSONEncodable(other)) {
|
||||
return new this(other.toJSON());
|
||||
}
|
||||
return new this(other);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ActionRowBuilder;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { SelectMenuOptionBuilder: BuildersSelectMenuOption } = require('@discordjs/builders');
|
||||
const { SelectMenuOptionBuilder: BuildersSelectMenuOption, isJSONEncodable } = require('@discordjs/builders');
|
||||
const Transformers = require('../util/Transformers');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
@@ -28,6 +28,18 @@ class SelectMenuOptionBuilder extends BuildersSelectMenuOption {
|
||||
}
|
||||
return super.setEmoji(emoji);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new select menu option builder from JSON data
|
||||
* @param {JSONEncodable<APISelectMenuOption>|APISelectMenuOption} other The other data
|
||||
* @returns {SelectMenuOptionBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
if (isJSONEncodable(other)) {
|
||||
return new this(other.toJSON());
|
||||
}
|
||||
return new this(other);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SelectMenuOptionBuilder;
|
||||
|
||||
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
@@ -610,7 +610,8 @@ export class SelectMenuBuilder extends BuilderSelectMenuComponent {
|
||||
|
||||
export class SelectMenuOptionBuilder extends BuildersSelectMenuOption {
|
||||
public constructor(data?: SelectMenuComponentOptionData | APISelectMenuOption);
|
||||
public setEmoji(emoji: ComponentEmojiResolvable): this;
|
||||
public override setEmoji(emoji: ComponentEmojiResolvable): this;
|
||||
public static from(other: JSONEncodable<APISelectMenuOption> | APISelectMenuOption): SelectMenuOptionBuilder;
|
||||
}
|
||||
|
||||
export class ModalBuilder extends BuildersModal {
|
||||
|
||||
Reference in New Issue
Block a user