Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
require('dotenv').config();
|
| 2 |
-
const { Client, GatewayIntentBits, Partials, Collection, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, UserSelectMenuBuilder, ComponentType } = require('discord.js');
|
| 3 |
const storage = require('./storage');
|
| 4 |
const roleStorage = require('./roleStorage');
|
| 5 |
const networkFix = require('./network_fix');
|
|
@@ -526,7 +526,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 526 |
}
|
| 527 |
|
| 528 |
if (interaction.commandName === 'friendly') {
|
| 529 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 530 |
const needed = interaction.options.getInteger('needed') || 7;
|
| 531 |
const content = `⭐▬▬▬▬▬ **FRIENDLY** ▬▬▬▬▬⭐\n🤝 Session\n🟩 I'm In\n🟥 Busy\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n🗳️ Needed: ${needed}\n@everyone`;
|
| 532 |
const msg = await interaction.reply({ content, fetchReply: true, allowedMentions: { parse: ['everyone'] } });
|
|
@@ -537,7 +537,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 537 |
}
|
| 538 |
|
| 539 |
if (interaction.commandName === 'leaguematch') {
|
| 540 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 541 |
const home = interaction.options.getString('home');
|
| 542 |
const away = interaction.options.getString('away');
|
| 543 |
const link = interaction.options.getString('link');
|
|
@@ -553,11 +553,11 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 553 |
.addOptions(TIMEZONE_OPTIONS)
|
| 554 |
);
|
| 555 |
|
| 556 |
-
await interaction.reply({ content: "🌍 **Select your timezone** to finalize the match schedule:", components: [row],
|
| 557 |
}
|
| 558 |
|
| 559 |
if (interaction.commandName === 'win' || interaction.commandName === 'loss' || interaction.commandName === 'draw') {
|
| 560 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 561 |
|
| 562 |
const type = interaction.commandName;
|
| 563 |
const res = interaction.options.getString('result');
|
|
@@ -603,7 +603,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 603 |
}
|
| 604 |
|
| 605 |
if (interaction.commandName === 'motm') {
|
| 606 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 607 |
const target = interaction.options.getUser('player');
|
| 608 |
storage.addStat(target.id, 'mvps');
|
| 609 |
const embed = UI.createEmbed("🌟 MAN OF THE MATCH", `The MVP award has been granted to <@${target.id}>!`, UI.colors.success);
|
|
@@ -636,7 +636,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 636 |
}
|
| 637 |
|
| 638 |
if (interaction.commandName === 'lineup') {
|
| 639 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 640 |
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 641 |
const row = new ActionRowBuilder().addComponents(
|
| 642 |
new StringSelectMenuBuilder()
|
|
@@ -649,20 +649,20 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 649 |
}
|
| 650 |
|
| 651 |
if (interaction.commandName === 'clear') {
|
| 652 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 653 |
const amount = interaction.options.getInteger('amount');
|
| 654 |
await interaction.channel.bulkDelete(amount, true);
|
| 655 |
await interaction.reply({ content: `✅ Cleared ${amount} messages.`, ephemeral: true });
|
| 656 |
}
|
| 657 |
|
| 658 |
if (interaction.commandName === 'lock') {
|
| 659 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 660 |
await interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone, { SendMessages: false });
|
| 661 |
await interaction.reply("🔒 Channel Locked.");
|
| 662 |
}
|
| 663 |
|
| 664 |
if (interaction.commandName === 'unlock') {
|
| 665 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 666 |
await interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone, { SendMessages: true });
|
| 667 |
await interaction.reply("🔓 Channel Unlocked.");
|
| 668 |
}
|
|
@@ -683,7 +683,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 683 |
}
|
| 684 |
|
| 685 |
if (interaction.commandName === 'sendlink') {
|
| 686 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 687 |
const link = interaction.options.getString('link');
|
| 688 |
await interaction.reply(`Link : ${link}`);
|
| 689 |
}
|
|
@@ -713,7 +713,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 713 |
}
|
| 714 |
|
| 715 |
if (interaction.commandName === 'managerlineup') {
|
| 716 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 717 |
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 718 |
const row = new ActionRowBuilder().addComponents(
|
| 719 |
new StringSelectMenuBuilder()
|
|
@@ -725,7 +725,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 725 |
}
|
| 726 |
|
| 727 |
if (interaction.commandName === 'lineupimage') {
|
| 728 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 729 |
await interaction.deferReply();
|
| 730 |
try {
|
| 731 |
const lineup = getGuildLineup(interaction.guildId);
|
|
@@ -1031,7 +1031,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1031 |
return;
|
| 1032 |
}
|
| 1033 |
|
| 1034 |
-
if (interaction.
|
| 1035 |
const guildId = interaction.guildId;
|
| 1036 |
guildSelectedFormation.set(guildId, interaction.values[0]);
|
| 1037 |
const map = new Map();
|
|
@@ -1072,7 +1072,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1072 |
const lineup = getGuildLineup(guildId);
|
| 1073 |
|
| 1074 |
if (interaction.customId.startsWith('man_edit_')) {
|
| 1075 |
-
if (!storage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission",
|
| 1076 |
const posKey = interaction.customId.replace('man_edit_', '');
|
| 1077 |
const row = new ActionRowBuilder().addComponents(
|
| 1078 |
new UserSelectMenuBuilder()
|
|
@@ -1119,14 +1119,14 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1119 |
|
| 1120 |
if (!matchData) {
|
| 1121 |
console.warn(`[TZ] Match data not found for ${matchId}`);
|
| 1122 |
-
return interaction.followUp({ content: "❌ Match session expired or bot restarted. Please try the command again.",
|
| 1123 |
}
|
| 1124 |
|
| 1125 |
const offset = parseFloat(interaction.values[0]);
|
| 1126 |
const baseTs = parseMatchTime(matchData.timeInput);
|
| 1127 |
|
| 1128 |
if (!baseTs) {
|
| 1129 |
-
return interaction.followUp({ content: "❌ Could not parse your time input. Use `9 PM` or `4/23 9 PM`.",
|
| 1130 |
}
|
| 1131 |
|
| 1132 |
const finalTs = baseTs - (offset * 3600);
|
|
@@ -1139,7 +1139,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1139 |
});
|
| 1140 |
|
| 1141 |
if (!channel) {
|
| 1142 |
-
return interaction.followUp({ content: "❌ Could not find the original channel. Please try again in a public channel.",
|
| 1143 |
}
|
| 1144 |
|
| 1145 |
const msg = await channel.send({ content, allowedMentions: { parse: ['everyone'] } });
|
|
@@ -1156,7 +1156,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 1156 |
} catch (err) {
|
| 1157 |
console.error("[TZ] Critical Error:", err);
|
| 1158 |
try {
|
| 1159 |
-
await interaction.followUp({ content: "❌ A system error occurred while processing your selection.",
|
| 1160 |
} catch(e) {}
|
| 1161 |
}
|
| 1162 |
return;
|
|
|
|
| 1 |
require('dotenv').config();
|
| 2 |
+
const { Client, GatewayIntentBits, Partials, Collection, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, UserSelectMenuBuilder, ComponentType, MessageFlags } = require('discord.js');
|
| 3 |
const storage = require('./storage');
|
| 4 |
const roleStorage = require('./roleStorage');
|
| 5 |
const networkFix = require('./network_fix');
|
|
|
|
| 526 |
}
|
| 527 |
|
| 528 |
if (interaction.commandName === 'friendly') {
|
| 529 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 530 |
const needed = interaction.options.getInteger('needed') || 7;
|
| 531 |
const content = `⭐▬▬▬▬▬ **FRIENDLY** ▬▬▬▬▬⭐\n🤝 Session\n🟩 I'm In\n🟥 Busy\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n🗳️ Needed: ${needed}\n@everyone`;
|
| 532 |
const msg = await interaction.reply({ content, fetchReply: true, allowedMentions: { parse: ['everyone'] } });
|
|
|
|
| 537 |
}
|
| 538 |
|
| 539 |
if (interaction.commandName === 'leaguematch') {
|
| 540 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 541 |
const home = interaction.options.getString('home');
|
| 542 |
const away = interaction.options.getString('away');
|
| 543 |
const link = interaction.options.getString('link');
|
|
|
|
| 553 |
.addOptions(TIMEZONE_OPTIONS)
|
| 554 |
);
|
| 555 |
|
| 556 |
+
await interaction.reply({ content: "🌍 **Select your timezone** to finalize the match schedule:", components: [row], flags: [MessageFlags.Ephemeral] });
|
| 557 |
}
|
| 558 |
|
| 559 |
if (interaction.commandName === 'win' || interaction.commandName === 'loss' || interaction.commandName === 'draw') {
|
| 560 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 561 |
|
| 562 |
const type = interaction.commandName;
|
| 563 |
const res = interaction.options.getString('result');
|
|
|
|
| 603 |
}
|
| 604 |
|
| 605 |
if (interaction.commandName === 'motm') {
|
| 606 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 607 |
const target = interaction.options.getUser('player');
|
| 608 |
storage.addStat(target.id, 'mvps');
|
| 609 |
const embed = UI.createEmbed("🌟 MAN OF THE MATCH", `The MVP award has been granted to <@${target.id}>!`, UI.colors.success);
|
|
|
|
| 636 |
}
|
| 637 |
|
| 638 |
if (interaction.commandName === 'lineup') {
|
| 639 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 640 |
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 641 |
const row = new ActionRowBuilder().addComponents(
|
| 642 |
new StringSelectMenuBuilder()
|
|
|
|
| 649 |
}
|
| 650 |
|
| 651 |
if (interaction.commandName === 'clear') {
|
| 652 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 653 |
const amount = interaction.options.getInteger('amount');
|
| 654 |
await interaction.channel.bulkDelete(amount, true);
|
| 655 |
await interaction.reply({ content: `✅ Cleared ${amount} messages.`, ephemeral: true });
|
| 656 |
}
|
| 657 |
|
| 658 |
if (interaction.commandName === 'lock') {
|
| 659 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 660 |
await interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone, { SendMessages: false });
|
| 661 |
await interaction.reply("🔒 Channel Locked.");
|
| 662 |
}
|
| 663 |
|
| 664 |
if (interaction.commandName === 'unlock') {
|
| 665 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 666 |
await interaction.channel.permissionOverwrites.edit(interaction.guild.roles.everyone, { SendMessages: true });
|
| 667 |
await interaction.reply("🔓 Channel Unlocked.");
|
| 668 |
}
|
|
|
|
| 683 |
}
|
| 684 |
|
| 685 |
if (interaction.commandName === 'sendlink') {
|
| 686 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 687 |
const link = interaction.options.getString('link');
|
| 688 |
await interaction.reply(`Link : ${link}`);
|
| 689 |
}
|
|
|
|
| 713 |
}
|
| 714 |
|
| 715 |
if (interaction.commandName === 'managerlineup') {
|
| 716 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 717 |
const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
|
| 718 |
const row = new ActionRowBuilder().addComponents(
|
| 719 |
new StringSelectMenuBuilder()
|
|
|
|
| 725 |
}
|
| 726 |
|
| 727 |
if (interaction.commandName === 'lineupimage') {
|
| 728 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 729 |
await interaction.deferReply();
|
| 730 |
try {
|
| 731 |
const lineup = getGuildLineup(interaction.guildId);
|
|
|
|
| 1031 |
return;
|
| 1032 |
}
|
| 1033 |
|
| 1034 |
+
if (interaction.isStringSelectMenu() && interaction.customId === 'manager_formation_select') {
|
| 1035 |
const guildId = interaction.guildId;
|
| 1036 |
guildSelectedFormation.set(guildId, interaction.values[0]);
|
| 1037 |
const map = new Map();
|
|
|
|
| 1072 |
const lineup = getGuildLineup(guildId);
|
| 1073 |
|
| 1074 |
if (interaction.customId.startsWith('man_edit_')) {
|
| 1075 |
+
if (!storage.isWhitelisted(interaction.guildId, interaction.member)) return interaction.reply({ content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 1076 |
const posKey = interaction.customId.replace('man_edit_', '');
|
| 1077 |
const row = new ActionRowBuilder().addComponents(
|
| 1078 |
new UserSelectMenuBuilder()
|
|
|
|
| 1119 |
|
| 1120 |
if (!matchData) {
|
| 1121 |
console.warn(`[TZ] Match data not found for ${matchId}`);
|
| 1122 |
+
return interaction.followUp({ content: "❌ Match session expired or bot restarted. Please try the command again.", flags: [MessageFlags.Ephemeral] });
|
| 1123 |
}
|
| 1124 |
|
| 1125 |
const offset = parseFloat(interaction.values[0]);
|
| 1126 |
const baseTs = parseMatchTime(matchData.timeInput);
|
| 1127 |
|
| 1128 |
if (!baseTs) {
|
| 1129 |
+
return interaction.followUp({ content: "❌ Could not parse your time input. Use `9 PM` or `4/23 9 PM`.", flags: [MessageFlags.Ephemeral] });
|
| 1130 |
}
|
| 1131 |
|
| 1132 |
const finalTs = baseTs - (offset * 3600);
|
|
|
|
| 1139 |
});
|
| 1140 |
|
| 1141 |
if (!channel) {
|
| 1142 |
+
return interaction.followUp({ content: "❌ Could not find the original channel. Please try again in a public channel.", flags: [MessageFlags.Ephemeral] });
|
| 1143 |
}
|
| 1144 |
|
| 1145 |
const msg = await channel.send({ content, allowedMentions: { parse: ['everyone'] } });
|
|
|
|
| 1156 |
} catch (err) {
|
| 1157 |
console.error("[TZ] Critical Error:", err);
|
| 1158 |
try {
|
| 1159 |
+
await interaction.followUp({ content: "❌ A system error occurred while processing your selection.", flags: [MessageFlags.Ephemeral] });
|
| 1160 |
} catch(e) {}
|
| 1161 |
}
|
| 1162 |
return;
|