3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

feat: add start_new_row option for role button options

This commit is contained in:
Dragory 2022-04-23 18:51:28 +03:00
parent 5042d9997f
commit 4a9ece8e3b
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
6 changed files with 57 additions and 35 deletions

View file

@ -4,8 +4,8 @@ import { isSnowflake, snowflakeRegex } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { Message, MessageButton, MessageEditOptions, MessageOptions, Snowflake } from "discord.js";
import { RoleButtonsItem } from "../../../data/entities/RoleButtonsItem";
import { splitButtonsIntoRows } from "./splitButtonsIntoRows";
import { buildCustomId } from "../../../utils/buildCustomId";
import { createButtonComponents } from "./createButtonComponents";
const channelMessageRegex = new RegExp(`^(${snowflakeRegex.source})-(${snowflakeRegex.source})$`);
@ -104,24 +104,8 @@ export async function applyRoleButtons(
}
// Apply role buttons
const buttons = configItem.options.map((opt, index) => {
const button = new MessageButton()
.setLabel(opt.label ?? "")
.setStyle(opt.style ?? "PRIMARY")
.setCustomId(buildCustomId("roleButtons", { name: configItem.name, index }));
if (opt.emoji) {
const emo = pluginData.client.emojis.resolve(opt.emoji as Snowflake) ?? opt.emoji;
button.setEmoji(emo);
}
return button;
});
const rows = splitButtonsIntoRows(buttons);
await message.edit({
components: rows,
});
const components = createButtonComponents(configItem);
await message.edit({ components });
return {
channel_id: message.channelId,