mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-23 03:50:09 +00:00
Compare commits
7 Commits
@discordjs
...
@discordjs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4476fadd19 | ||
|
|
61251cfcb8 | ||
|
|
e77793898a | ||
|
|
f5b3f842e3 | ||
|
|
e32f0c141a | ||
|
|
fdac8c5bdd | ||
|
|
0d64ea0528 |
@@ -2,6 +2,16 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
# [@discordjs/builders@1.13.1](https://github.com/discordjs/discord.js/compare/@discordjs/builders@1.13.0...@discordjs/builders@1.13.1) - (2025-11-30)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- Adjust label predicates (#11318) ([61251cf](https://github.com/discordjs/discord.js/commit/61251cfcb842cc468aca7a581f54be4fd28c2721))
|
||||
|
||||
## Documentation
|
||||
|
||||
- **Container:** Update example usage ([e777938](https://github.com/discordjs/discord.js/commit/e77793898ac36320eeee8b999c618918526ab9c2))
|
||||
|
||||
# [@discordjs/builders@1.13.0](https://github.com/discordjs/discord.js/compare/@discordjs/builders@1.12.2...@discordjs/builders@1.13.0) - (2025-10-24)
|
||||
|
||||
## Features
|
||||
|
||||
@@ -6,6 +6,10 @@ const selectMenu = () => new StringSelectMenuBuilder();
|
||||
const selectMenuOption = () => new StringSelectMenuOptionBuilder();
|
||||
|
||||
const longStr = 'a'.repeat(256);
|
||||
const selectMenuOptionLabelAtLimit = 'a'.repeat(100);
|
||||
const selectMenuOptionLabelAboveLimit = 'a'.repeat(101);
|
||||
const selectMenuOptionValueAboveLimit = 'a'.repeat(101);
|
||||
const selectMenuOptionDescriptionAboveLimit = 'a'.repeat(101);
|
||||
|
||||
const selectMenuOptionData: APISelectMenuOption = {
|
||||
label: 'test',
|
||||
@@ -53,12 +57,12 @@ describe('Select Menu Components', () => {
|
||||
expect(() => selectMenu().setDisabled()).not.toThrowError();
|
||||
expect(() => selectMenu().setPlaceholder('description')).not.toThrowError();
|
||||
const option = selectMenuOption()
|
||||
.setLabel('test')
|
||||
.setLabel(selectMenuOptionLabelAtLimit)
|
||||
.setValue('test')
|
||||
.setDefault(true)
|
||||
.setEmoji({ name: 'test' })
|
||||
.setDescription('description');
|
||||
expect(() => selectMenu().addOptions(option)).not.toThrowError();
|
||||
expect(() => selectMenu().setCustomId('customId').addOptions(option).toJSON()).not.toThrowError();
|
||||
expect(() => selectMenu().setOptions(option)).not.toThrowError();
|
||||
expect(() => selectMenu().setOptions({ label: 'test', value: 'test' })).not.toThrowError();
|
||||
expect(() => selectMenu().addOptions([option])).not.toThrowError();
|
||||
@@ -156,13 +160,13 @@ describe('Select Menu Components', () => {
|
||||
|
||||
expect(() => {
|
||||
selectMenuOption()
|
||||
.setLabel(longStr)
|
||||
.setValue(longStr)
|
||||
.setLabel(selectMenuOptionLabelAboveLimit)
|
||||
.setValue(selectMenuOptionValueAboveLimit)
|
||||
// @ts-expect-error: Invalid default value
|
||||
.setDefault(-1)
|
||||
// @ts-expect-error: Invalid emoji
|
||||
.setEmoji({ name: 1 })
|
||||
.setDescription(longStr);
|
||||
.setDescription(selectMenuOptionDescriptionAboveLimit);
|
||||
}).toThrowError();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "@discordjs/builders",
|
||||
"version": "1.13.0",
|
||||
"version": "1.13.1",
|
||||
"description": "A set of builders that you can use when creating your bot",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
|
||||
@@ -50,6 +50,9 @@ export const labelValueDescriptionValidator = s
|
||||
.lengthLessThanOrEqual(100)
|
||||
.setValidationEnabled(isValidationEnabled);
|
||||
|
||||
/**
|
||||
* @deprecated Replaced with selectMenuStringOptionPredicate.
|
||||
*/
|
||||
export const jsonOptionValidator = s
|
||||
.object({
|
||||
label: labelValueDescriptionValidator,
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Result, s } from '@sapphire/shapeshift';
|
||||
import { ChannelType, ComponentType, SelectMenuDefaultValueType } from 'discord-api-types/v10';
|
||||
import { isValidationEnabled } from '../../util/validation.js';
|
||||
import { customIdValidator, emojiValidator, idValidator } from '../Assertions.js';
|
||||
import { labelValidator } from '../textInput/Assertions.js';
|
||||
|
||||
const selectMenuBasePredicate = s.object({
|
||||
id: idValidator.optional(),
|
||||
@@ -63,7 +62,7 @@ export const selectMenuUserPredicate = selectMenuBasePredicate
|
||||
|
||||
export const selectMenuStringOptionPredicate = s
|
||||
.object({
|
||||
label: labelValidator,
|
||||
label: s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100),
|
||||
value: s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100),
|
||||
description: s.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).optional(),
|
||||
emoji: emojiValidator.optional(),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ComponentType } from 'discord-api-types/v10';
|
||||
import type { APIStringSelectComponent, APISelectMenuOption } from 'discord-api-types/v10';
|
||||
import { normalizeArray, type RestOrArray } from '../../util/normalizeArray.js';
|
||||
import { jsonOptionValidator, optionsLengthValidator, validateRequiredSelectMenuParameters } from '../Assertions.js';
|
||||
import { optionsLengthValidator, validateRequiredSelectMenuParameters } from '../Assertions.js';
|
||||
import { selectMenuStringOptionPredicate } from './Assertions.js';
|
||||
import { BaseSelectMenuBuilder } from './BaseSelectMenu.js';
|
||||
import { StringSelectMenuOptionBuilder } from './StringSelectMenuOption.js';
|
||||
|
||||
@@ -63,7 +64,7 @@ export class StringSelectMenuBuilder extends BaseSelectMenuBuilder<APIStringSele
|
||||
...normalizedOptions.map((normalizedOption) =>
|
||||
normalizedOption instanceof StringSelectMenuOptionBuilder
|
||||
? normalizedOption
|
||||
: new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption)),
|
||||
: new StringSelectMenuOptionBuilder(selectMenuStringOptionPredicate.parse(normalizedOption)),
|
||||
),
|
||||
);
|
||||
return this;
|
||||
@@ -120,7 +121,7 @@ export class StringSelectMenuBuilder extends BaseSelectMenuBuilder<APIStringSele
|
||||
...normalizedOptions.map((normalizedOption) =>
|
||||
normalizedOption instanceof StringSelectMenuOptionBuilder
|
||||
? normalizedOption
|
||||
: new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption)),
|
||||
: new StringSelectMenuOptionBuilder(selectMenuStringOptionPredicate.parse(normalizedOption)),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ export class ContainerBuilder extends ComponentBuilder<APIContainerComponent> {
|
||||
* },
|
||||
* ],
|
||||
* })
|
||||
* .addComponents(separator, section);
|
||||
* .addSeparatorComponents(separator)
|
||||
* .addSectionComponents(section);
|
||||
* ```
|
||||
*/
|
||||
public constructor({ components, ...data }: Partial<APIContainerComponent> = {}) {
|
||||
|
||||
@@ -31,6 +31,7 @@ export {
|
||||
*/
|
||||
StringSelectMenuOptionBuilder as SelectMenuOptionBuilder,
|
||||
} from './components/selectMenu/StringSelectMenuOption.js';
|
||||
export * as SelectMenuAssertions from './components/selectMenu/Assertions.js';
|
||||
export * from './components/selectMenu/StringSelectMenuOption.js';
|
||||
export * from './components/selectMenu/UserSelectMenu.js';
|
||||
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
# [14.25.1](https://github.com/discordjs/discord.js/compare/14.25.0...14.25.1) - (2025-11-21)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **GuildEmojiManager:** Allow `CreateGuildExpressions` for retrieving author data (#11288) ([0d64ea0](https://github.com/discordjs/discord.js/commit/0d64ea0528b1591ef9b856b9bcad52e88e2cbd05))
|
||||
|
||||
# [14.25.0](https://github.com/discordjs/discord.js/compare/14.24.2...14.25.0) - (2025-11-18)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "discord.js",
|
||||
"version": "14.25.0",
|
||||
"version": "14.25.1",
|
||||
"description": "A powerful library for interacting with the Discord API",
|
||||
"scripts": {
|
||||
"test": "pnpm run docs:test && pnpm run test:typescript",
|
||||
|
||||
@@ -11,15 +11,19 @@ const Messages = require('./Messages');
|
||||
* @ignore
|
||||
*/
|
||||
function makeDiscordjsError(Base) {
|
||||
return class DiscordjsError extends Base {
|
||||
return class extends Base {
|
||||
static {
|
||||
Object.defineProperty(this, 'name', { value: `Discordjs${Base.name}` });
|
||||
}
|
||||
|
||||
constructor(code, ...args) {
|
||||
super(message(code, args));
|
||||
this.code = code;
|
||||
Error.captureStackTrace?.(this, DiscordjsError);
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
|
||||
get name() {
|
||||
return `${super.name} [${this.code}]`;
|
||||
return `${this.constructor.name} [${this.code}]`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -115,7 +115,8 @@ const Messages = {
|
||||
[DjsErrorCodes.EmojiType]: 'Emoji must be a string or GuildEmoji/ReactionEmoji',
|
||||
[DjsErrorCodes.EmojiManaged]: 'Emoji is managed and has no Author.',
|
||||
[DjsErrorCodes.MissingManageGuildExpressionsPermission]: guild =>
|
||||
`Client must have Manage Guild Expressions permission in guild ${guild} to see emoji authors.`,
|
||||
// eslint-disable-next-line max-len
|
||||
`Client must have Create Guild Expressions or Manage Guild Expressions permission in guild ${guild} to see emoji authors.`,
|
||||
[DjsErrorCodes.MissingManageEmojisAndStickersPermission]: guild =>
|
||||
`Client must have Manage Emojis and Stickers permission in guild ${guild} to see emoji authors.`,
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ class GuildEmojiManager extends BaseGuildEmojiManager {
|
||||
|
||||
const { me } = this.guild.members;
|
||||
if (!me) throw new DiscordjsError(ErrorCodes.GuildUncachedMe);
|
||||
if (!me.permissions.has(PermissionFlagsBits.ManageGuildExpressions)) {
|
||||
if (!me.permissions.any(PermissionFlagsBits.CreateGuildExpressions | PermissionFlagsBits.ManageGuildExpressions)) {
|
||||
throw new DiscordjsError(ErrorCodes.MissingManageGuildExpressionsPermission, this.guild);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user