3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

fix: only allow named options for role button style

Numbered options gave an error when used.
This commit is contained in:
Dragory 2022-04-23 20:11:46 +03:00
parent a627c7d859
commit 22bd0ec422
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -3,19 +3,20 @@ import { BasePluginType } from "knub";
import { tMessageContent, tNullable } from "../../utils";
import { GuildRoleButtons } from "../../data/GuildRoleButtons";
enum ButtonStyles {
PRIMARY = 1,
SECONDARY = 2,
SUCCESS = 3,
DANGER = 4,
// LINK = 5, We do not want users to create link buttons, but it would be style 5
}
const RoleButtonOption = t.type({
role_id: t.string,
label: tNullable(t.string),
emoji: tNullable(t.string),
style: tNullable(t.keyof(ButtonStyles)), // https://discord.js.org/#/docs/discord.js/v13/typedef/MessageButtonStyle
// https://discord.js.org/#/docs/discord.js/v13/typedef/MessageButtonStyle
style: tNullable(
t.union([
t.literal("PRIMARY"),
t.literal("SECONDARY"),
t.literal("SUCCESS"),
t.literal("DANGER"),
// t.literal("LINK"), // Role buttons don't use link buttons, but adding this here so it's documented why it's not available
]),
),
start_new_row: tNullable(t.boolean),
});
export type TRoleButtonOption = t.TypeOf<typeof RoleButtonOption>;