mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 08:50:07 +00:00
@@ -1,7 +1,7 @@
|
||||
import { ButtonComponent } from "./button_component.ts";
|
||||
import { SelectMenuComponent } from "./select_menu.ts";
|
||||
|
||||
// TODO: add docs link
|
||||
/** https://discord.com/developers/docs/interactions/message-components#actionrow */
|
||||
export interface ActionRow {
|
||||
/** Action rows are a group of buttons. */
|
||||
type: 1;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { SnakeCasedPropertiesDeep } from "../../util.ts";
|
||||
import { ButtonStyles } from "./button_styles.ts";
|
||||
import { DiscordMessageComponentTypes } from "./message_component_types.ts";
|
||||
|
||||
// TODO: add docs link
|
||||
/** https://discord.com/developers/docs/interactions/message-components#buttons-button-object */
|
||||
export interface ButtonComponent {
|
||||
/** All button components have type 2 */
|
||||
type: 2;
|
||||
type: DiscordMessageComponentTypes.Button;
|
||||
/** for what the button says (max 80 characters) */
|
||||
label: string;
|
||||
/** a dev-defined unique string sent on click (max 100 characters). type 5 Link buttons can not have a custom_id */
|
||||
@@ -28,4 +29,5 @@ export interface ButtonComponent {
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
// TODO: v12 remove this
|
||||
export type DiscordButtonComponent = SnakeCasedPropertiesDeep<ButtonComponent>;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { DiscordMessageComponentTypes } from "./message_component_types.ts";
|
||||
|
||||
export interface ButtonData {
|
||||
/** with the value you defined for this component */
|
||||
customId: string;
|
||||
/** The type of this component */
|
||||
componentType: 2;
|
||||
componentType: DiscordMessageComponentTypes.Button;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// TODO: add docs link
|
||||
/** https://discord.com/developers/docs/interactions/message-components#buttons-button-styles */
|
||||
export enum DiscordButtonStyles {
|
||||
/** A blurple button */
|
||||
Primary = 1,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// TODO: add docs link
|
||||
/** https://discord.com/developers/docs/interactions/message-components#component-types */
|
||||
export enum DiscordMessageComponentTypes {
|
||||
/** A row of components at the bottom of a message */
|
||||
ActionRow = 1,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { DiscordMessageComponentTypes } from "./message_component_types.ts";
|
||||
|
||||
// TODO: add dock link
|
||||
export interface SelectMenuData {
|
||||
/** The type of component */
|
||||
componentType: DiscordMessageComponentTypes.SelectMenu;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { DiscordMessageComponentTypes } from "./message_component_types.ts";
|
||||
import { SelectOption } from "./select_option.ts";
|
||||
|
||||
// TODO: add dock link
|
||||
export interface SelectMenuComponent {
|
||||
type: DiscordMessageComponentTypes.SelectMenu;
|
||||
/** A custom identifier for this component. Maximum 100 characters. */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// TODO: add dock link
|
||||
export interface SelectOption {
|
||||
/** The user-facing name of the option. Maximum 25 characters. */
|
||||
label: string;
|
||||
|
||||
@@ -81,7 +81,10 @@ export async function dispatchRequirements(data: DiscordGatewayPayload, shardId:
|
||||
);
|
||||
}
|
||||
|
||||
const guild = await structures.createDiscordenoGuild(rawGuild, shardId);
|
||||
const guild = await structures.createDiscordenoGuild(
|
||||
{ ...rawGuild, memberCount: rawGuild.approximateMemberCount },
|
||||
shardId
|
||||
);
|
||||
|
||||
// Add to cache
|
||||
cache.guilds.set(id, guild);
|
||||
|
||||
@@ -236,11 +236,11 @@ export function validateComponents(components: MessageComponents) {
|
||||
|
||||
// 5 Link buttons can not have a customId
|
||||
if (isButton(subcomponent)) {
|
||||
if (subcomponent.type === ButtonStyles.Link && subcomponent.customId) {
|
||||
if (subcomponent.style === ButtonStyles.Link && subcomponent.customId) {
|
||||
throw new Error(Errors.LINK_BUTTON_CANNOT_HAVE_CUSTOM_ID);
|
||||
}
|
||||
// Other buttons must have a customId
|
||||
if (!subcomponent.customId && subcomponent.type !== ButtonStyles.Link) {
|
||||
if (!subcomponent.customId && subcomponent.style !== ButtonStyles.Link) {
|
||||
throw new Error(Errors.BUTTON_REQUIRES_CUSTOM_ID);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user