Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New select menus #8775

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c31cb23
Select Menus Builders
jaw0r3k Oct 14, 2022
d9d9720
feat(builders): new select menus
RedGuy12 Oct 14, 2022
4f1e627
Handle resolved
jaw0r3k Oct 14, 2022
d87199d
feat: update re-exported builders in djs
RedGuy12 Oct 14, 2022
d2cbbf3
Merge branch 'new-select-menus' of https://github.com/jaw0r3k/discord…
jaw0r3k Oct 14, 2022
e0b0898
Some typings
jaw0r3k Oct 14, 2022
5a3ea6a
fix: these builders don't have options
RedGuy12 Oct 14, 2022
7cc5b2d
feat: `SelectMenuComponent#channelTypes`
RedGuy12 Oct 14, 2022
5965e09
fix: don't construct unnecessary `Collection`s
RedGuy12 Oct 14, 2022
87c38e4
Merge remote-tracking branch 'origin/main' into new-select-menus
RedGuy12 Oct 14, 2022
d9fec21
Add typwguards
jaw0r3k Oct 17, 2022
9c20d57
Typeguards v2
jaw0r3k Oct 18, 2022
6c79811
Forgotten type
jaw0r3k Oct 18, 2022
a7f63c2
fix: better typeguard names
RedGuy12 Oct 19, 2022
e94fe28
Split them into classes
jaw0r3k Oct 21, 2022
f6b240e
Jsdocs change
jaw0r3k Oct 21, 2022
b164851
Handle new interaction types
jaw0r3k Oct 21, 2022
6f446b9
Type changes
jaw0r3k Oct 21, 2022
89a0ff9
Add SelectMenuTypes
jaw0r3k Oct 21, 2022
f85f2ec
make it one class again
RedGuy12 Oct 21, 2022
f757dff
Merge branch 'new-select-menus' of https://github.com/jaw0r3k/discord…
RedGuy12 Oct 21, 2022
2de0322
type tests
RedGuy12 Oct 21, 2022
c4089c7
Revert "type tests"
jaw0r3k Oct 21, 2022
6cf241c
Revert "make it one class again"
jaw0r3k Oct 21, 2022
82952bf
Merge branch 'main' into new-select-menus
RedGuy12 Oct 22, 2022
49fe123
Update index.d.ts
jaw0r3k Oct 22, 2022
0e1d6b3
Update packages/discord.js/typings/index.test-d.ts
jaw0r3k Oct 23, 2022
64ce799
Format
jaw0r3k Oct 23, 2022
2a54e29
Merge branch 'new-select-menus' of https://github.com/jaw0r3k/discord…
jaw0r3k Oct 23, 2022
7758546
Remove missplaced [
jaw0r3k Oct 23, 2022
c988888
split SelectMenuComponentData
jaw0r3k Oct 24, 2022
d342d64
Apply suggestions from code review
jaw0r3k Oct 25, 2022
8a74365
Apply suggestions from code review
jaw0r3k Oct 25, 2022
98b92da
Merge branch 'new-select-menus' of https://github.com/jaw0r3k/discord…
jaw0r3k Oct 25, 2022
33698c9
feat: bump discord-api-types
jaw0r3k Oct 28, 2022
d9f801e
fix: some improvments
jaw0r3k Oct 28, 2022
f77c4bf
Hello World!
jaw0r3k Oct 28, 2022
600ae37
Add channel_types to json
jaw0r3k Oct 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/discord.js/src/structures/BaseInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { DiscordSnowflake } = require('@sapphire/snowflake');
const { InteractionType, ApplicationCommandType, ComponentType } = require('discord-api-types/v10');
const Base = require('./Base');
const { SelectMenuTypes } = require('../util/Constants');
const PermissionsBitField = require('../util/PermissionsBitField');

/**
Expand Down Expand Up @@ -274,14 +275,7 @@ class BaseInteraction extends Base {
*/
isSelectMenu() {
return (
this.type === InteractionType.MessageComponent &&
[
ComponentType.StringSelect,
ComponentType.UserSelect,
ComponentType.RoleSelect,
ComponentType.MentionableSelect,
ComponentType.ChannelSelect,
].includes(this.componentType)
this.type === InteractionType.MessageComponent && SelectMenuTypes.includes(this.componentType)
);
}
/**
Expand Down
19 changes: 18 additions & 1 deletion packages/discord.js/src/util/Constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { ChannelType, MessageType } = require('discord-api-types/v10');
const { ChannelType, MessageType, ComponentType } = require('discord-api-types/v10');

/**
* The name of an item to be swept in Sweepers
Expand Down Expand Up @@ -113,11 +113,28 @@ exports.ThreadChannelTypes = [ChannelType.AnnouncementThread, ChannelType.Public
*/
exports.VoiceBasedChannelTypes = [ChannelType.GuildVoice, ChannelType.GuildStageVoice];

/**
* The types of select menus. The available types are:
* * {@link ComponentType.StringSelect}
* * @link ComponentType.UserSelect}
* * {@link ComponentType.RoleSelect}
* * {@link ComponentType.MentionableSelect}
* * {@link ComponentType.ChannelSelect}
* @typedef {ChannelType[]} SelectMenuTypes
jaw0r3k marked this conversation as resolved.
Show resolved Hide resolved
*/
exports.SelectMenuTypes = [
ComponentType.StringSelect,
ComponentType.UserSelect,
ComponentType.RoleSelect,
ComponentType.MentionableSelect,
ComponentType.ChannelSelect,
];
/**
* @typedef {Object} Constants Constants that can be used in an enum or object-like way.
* @property {SweeperKey[]} SweeperKeys The possible names of items that can be swept in sweepers
* @property {NonSystemMessageTypes} NonSystemMessageTypes The types of messages that are not deemed a system type
* @property {TextBasedChannelTypes} TextBasedChannelTypes The types of channels that are text-based
* @property {ThreadChannelTypes} ThreadChannelTypes The types of channels that are threads
* @property {VoiceBasedChannelTypes} VoiceBasedChannelTypes The types of channels that are voice-based
* @property {SelectMenuTypes} SelectMenuTypes The types of components that are select menus.
*/
15 changes: 7 additions & 8 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2286,8 +2286,11 @@ export class Role extends Base {
public toString(): RoleMention;
}

export type SelectMenuType =
|;
export type SelectMenuTypes = ComponentType.StringSelect |
jaw0r3k marked this conversation as resolved.
Show resolved Hide resolved
ComponentType.UserSelect |
ComponentType.RoleSelect |
ComponentType.MentionableSelect|
ComponentType.ChannelSelect;
export type AnySelectMenuInteraction<Cached extends CacheType = CacheType> = StringSelectMenuInteraction<Cached> | ChannelSelectMenuInteraction<Cached> | UserSelectMenuInteraction<Cached> | RoleSelectMenuInteraction<Cached> | MentiobnableSelectMenuInteraction<Cached>;

export class SelectMenuInteraction<Cached extends CacheType = CacheType> extends MessageComponentInteraction<Cached> {
Expand All @@ -2299,11 +2302,7 @@ export class SelectMenuInteraction<Cached extends CacheType = CacheType> extends
SelectMenuComponent | APISelectMenuComponent,
SelectMenuComponent | APISelectMenuComponent
>;
public componentType: ComponentType.StringSelect |
ComponentType.UserSelect |
ComponentType.RoleSelect |
ComponentType.MentionableSelect|
ComponentType.ChannelSelect;
public componentType: SelectMenuTypes;
public values: string[];
public inGuild(): this is SelectMenuInteraction<'raw' | 'cached'>;
public inCachedGuild(): this is SelectMenuInteraction<'cached'>;
Expand Down Expand Up @@ -5429,7 +5428,7 @@ export interface MessageReference {
export type MessageResolvable = Message | Snowflake;

export interface SelectMenuComponentData extends BaseComponentData {
type: ComponentType.StringSelect | ComponentType.UserSelect | ComponentType.RoleSelect | ComponentType.ChannelSelect | ComponentType.MentionableSelect ;
type: SelectMenuTypes ;
customId: string;
disabled?: boolean;
maxValues?: number;
Expand Down