Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -318,6 +318,7 @@ client.on('messageCreate', async (message) => {
|
|
| 318 |
|
| 319 |
if (commandName === 'lineup') {
|
| 320 |
if (!roleStorage.isWhitelisted(message.guildId, message.member)) return message.reply("❌ No Permission");
|
|
|
|
| 321 |
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 322 |
const row = new ActionRowBuilder().addComponents(
|
| 323 |
new StringSelectMenuBuilder()
|
|
@@ -773,6 +774,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 773 |
|
| 774 |
if (interaction.commandName === 'lineup') {
|
| 775 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return safeReply(interaction, { content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
|
|
|
| 776 |
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 777 |
const row = new ActionRowBuilder().addComponents(
|
| 778 |
new StringSelectMenuBuilder()
|
|
@@ -994,8 +996,14 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 994 |
}
|
| 995 |
}
|
| 996 |
|
| 997 |
-
if (interaction.
|
| 998 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission.", ephemeral: true });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 999 |
const guildId = interaction.guildId;
|
| 1000 |
guildSelectedFormation.set(guildId, interaction.values[0]);
|
| 1001 |
guildLineups.set(guildId, new Map());
|
|
@@ -1005,6 +1013,12 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1005 |
|
| 1006 |
if (interaction.isStringSelectMenu() && interaction.customId === 'formation_select') {
|
| 1007 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission to change formations.", flags: [MessageFlags.Ephemeral] });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1008 |
const guildId = interaction.guildId;
|
| 1009 |
guildSelectedFormation.set(guildId, interaction.values[0]);
|
| 1010 |
const map = new Map();
|
|
@@ -1086,6 +1100,12 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1086 |
|
| 1087 |
if (interaction.customId === 'lineup_clear') {
|
| 1088 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1089 |
lineupBoard.clear();
|
| 1090 |
await interaction.update(createLineupView(lineupGuildId));
|
| 1091 |
return;
|
|
@@ -1093,6 +1113,12 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1093 |
|
| 1094 |
if (interaction.customId === 'lineup_done') {
|
| 1095 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1096 |
await interaction.deferReply();
|
| 1097 |
const formKey = guildSelectedFormation.get(lineupGuildId) || 'default';
|
| 1098 |
const attachment = await createLineupAttachment(lineupBoard, formKey, FORMATIONS[formKey], client);
|
|
@@ -1267,6 +1293,7 @@ const FORMATIONS = {
|
|
| 1267 |
|
| 1268 |
const guildLineups = new Map();
|
| 1269 |
const guildSelectedFormation = new Map();
|
|
|
|
| 1270 |
|
| 1271 |
function getGuildLineup(guildId) {
|
| 1272 |
if (!guildLineups.get(guildId)) guildLineups.set(guildId, new Map());
|
|
@@ -1282,7 +1309,13 @@ function createLineupView(guildId) {
|
|
| 1282 |
for (const [posKey, posLabel] of formation) {
|
| 1283 |
const players = lineup.get(posKey) || [];
|
| 1284 |
if (players.length > 0) {
|
| 1285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1286 |
} else {
|
| 1287 |
text += `⬛ **${posLabel}** ➔ *Open*\n\n`;
|
| 1288 |
}
|
|
|
|
| 318 |
|
| 319 |
if (commandName === 'lineup') {
|
| 320 |
if (!roleStorage.isWhitelisted(message.guildId, message.member)) return message.reply("❌ No Permission");
|
| 321 |
+
lineupOwners.set(message.guildId, message.author.id);
|
| 322 |
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 323 |
const row = new ActionRowBuilder().addComponents(
|
| 324 |
new StringSelectMenuBuilder()
|
|
|
|
| 774 |
|
| 775 |
if (interaction.commandName === 'lineup') {
|
| 776 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return safeReply(interaction, { content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 777 |
+
lineupOwners.set(interaction.guildId, interaction.user.id);
|
| 778 |
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 779 |
const row = new ActionRowBuilder().addComponents(
|
| 780 |
new StringSelectMenuBuilder()
|
|
|
|
| 996 |
}
|
| 997 |
}
|
| 998 |
|
| 999 |
+
if (interaction.isStringSelectMenu() && interaction.customId === 'formation_select_initial') {
|
| 1000 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission.", ephemeral: true });
|
| 1001 |
+
|
| 1002 |
+
const ownerId = lineupOwners.get(interaction.guildId);
|
| 1003 |
+
if (ownerId && interaction.user.id !== ownerId) {
|
| 1004 |
+
return interaction.reply({ content: `❌ Only <@${ownerId}> can initialize this lineup!`, ephemeral: true });
|
| 1005 |
+
}
|
| 1006 |
+
|
| 1007 |
const guildId = interaction.guildId;
|
| 1008 |
guildSelectedFormation.set(guildId, interaction.values[0]);
|
| 1009 |
guildLineups.set(guildId, new Map());
|
|
|
|
| 1013 |
|
| 1014 |
if (interaction.isStringSelectMenu() && interaction.customId === 'formation_select') {
|
| 1015 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission to change formations.", flags: [MessageFlags.Ephemeral] });
|
| 1016 |
+
|
| 1017 |
+
const ownerId = lineupOwners.get(interaction.guildId);
|
| 1018 |
+
if (ownerId && interaction.user.id !== ownerId) {
|
| 1019 |
+
return interaction.reply({ content: `❌ Only <@${ownerId}> can change the formation!`, ephemeral: true });
|
| 1020 |
+
}
|
| 1021 |
+
|
| 1022 |
const guildId = interaction.guildId;
|
| 1023 |
guildSelectedFormation.set(guildId, interaction.values[0]);
|
| 1024 |
const map = new Map();
|
|
|
|
| 1100 |
|
| 1101 |
if (interaction.customId === 'lineup_clear') {
|
| 1102 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 1103 |
+
|
| 1104 |
+
const ownerId = lineupOwners.get(interaction.guildId);
|
| 1105 |
+
if (ownerId && interaction.user.id !== ownerId) {
|
| 1106 |
+
return interaction.reply({ content: `❌ Only <@${ownerId}> can clear the board!`, ephemeral: true });
|
| 1107 |
+
}
|
| 1108 |
+
|
| 1109 |
lineupBoard.clear();
|
| 1110 |
await interaction.update(createLineupView(lineupGuildId));
|
| 1111 |
return;
|
|
|
|
| 1113 |
|
| 1114 |
if (interaction.customId === 'lineup_done') {
|
| 1115 |
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 1116 |
+
|
| 1117 |
+
const ownerId = lineupOwners.get(interaction.guildId);
|
| 1118 |
+
if (ownerId && interaction.user.id !== ownerId) {
|
| 1119 |
+
return interaction.reply({ content: `❌ Only <@${ownerId}> can generate the final image!`, ephemeral: true });
|
| 1120 |
+
}
|
| 1121 |
+
|
| 1122 |
await interaction.deferReply();
|
| 1123 |
const formKey = guildSelectedFormation.get(lineupGuildId) || 'default';
|
| 1124 |
const attachment = await createLineupAttachment(lineupBoard, formKey, FORMATIONS[formKey], client);
|
|
|
|
| 1293 |
|
| 1294 |
const guildLineups = new Map();
|
| 1295 |
const guildSelectedFormation = new Map();
|
| 1296 |
+
const lineupOwners = new Map();
|
| 1297 |
|
| 1298 |
function getGuildLineup(guildId) {
|
| 1299 |
if (!guildLineups.get(guildId)) guildLineups.set(guildId, new Map());
|
|
|
|
| 1309 |
for (const [posKey, posLabel] of formation) {
|
| 1310 |
const players = lineup.get(posKey) || [];
|
| 1311 |
if (players.length > 0) {
|
| 1312 |
+
const starter = players[0];
|
| 1313 |
+
const subs = players.slice(1);
|
| 1314 |
+
let line = `🟩 **${posLabel}** ➔ <@${starter}>`;
|
| 1315 |
+
if (subs.length > 0) {
|
| 1316 |
+
line += ` (Substitute: ` + subs.map(p => `<@${p}>`).join(', ') + `)`;
|
| 1317 |
+
}
|
| 1318 |
+
text += line + "\n\n";
|
| 1319 |
} else {
|
| 1320 |
text += `⬛ **${posLabel}** ➔ *Open*\n\n`;
|
| 1321 |
}
|