Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -576,29 +576,44 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 576 |
if (interaction.commandName !== 'ping') {
|
| 577 |
await interaction.deferReply({ ephemeral: true }).catch(() => {});
|
| 578 |
}
|
| 579 |
-
|
| 580 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 581 |
|
| 582 |
-
|
| 583 |
logTransaction(client, interaction.commandName, interaction.user, interaction.guild, interaction.member);
|
| 584 |
|
| 585 |
if (interaction.commandName === 'ping') {
|
| 586 |
-
await
|
| 587 |
}
|
| 588 |
|
| 589 |
if (interaction.commandName === 'friendly') {
|
| 590 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return
|
| 591 |
const needed = interaction.options.getInteger('needed') || 7;
|
| 592 |
const content = `⭐▬▬▬▬▬ **FRIENDLY** ▬▬▬▬▬⭐\n🤝 Session\n🟩 I'm In\n🟥 Busy\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n🗳️ Needed: ${needed}\n@everyone`;
|
| 593 |
-
const msg = await
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
|
|
|
|
|
|
| 598 |
}
|
| 599 |
|
| 600 |
if (interaction.commandName === 'leaguematch') {
|
| 601 |
-
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return
|
| 602 |
const home = interaction.options.getString('home');
|
| 603 |
const away = interaction.options.getString('away');
|
| 604 |
const link = interaction.options.getString('link');
|
|
@@ -614,7 +629,7 @@ client.on('interactionCreate', async (interaction) => {
|
|
| 614 |
.addOptions(TIMEZONE_OPTIONS)
|
| 615 |
);
|
| 616 |
|
| 617 |
-
await
|
| 618 |
}
|
| 619 |
|
| 620 |
if (interaction.commandName === 'win' || interaction.commandName === 'loss' || interaction.commandName === 'draw') {
|
|
|
|
| 576 |
if (interaction.commandName !== 'ping') {
|
| 577 |
await interaction.deferReply({ ephemeral: true }).catch(() => {});
|
| 578 |
}
|
| 579 |
+
} catch (e) {}
|
| 580 |
}
|
| 581 |
+
});
|
| 582 |
+
|
| 583 |
+
async function safeReply(interaction, options) {
|
| 584 |
+
try {
|
| 585 |
+
if (interaction.deferred || interaction.replied) {
|
| 586 |
+
return await interaction.editReply(options);
|
| 587 |
+
} else {
|
| 588 |
+
return await interaction.reply(options);
|
| 589 |
+
}
|
| 590 |
+
} catch (e) {
|
| 591 |
+
console.error(`[!] Reply Failed: ${e.message}`);
|
| 592 |
+
}
|
| 593 |
+
}
|
| 594 |
|
| 595 |
+
if (interaction.isChatInputCommand()) {
|
| 596 |
logTransaction(client, interaction.commandName, interaction.user, interaction.guild, interaction.member);
|
| 597 |
|
| 598 |
if (interaction.commandName === 'ping') {
|
| 599 |
+
await safeReply(interaction, `Latency: ${client.ws.ping}ms`);
|
| 600 |
}
|
| 601 |
|
| 602 |
if (interaction.commandName === 'friendly') {
|
| 603 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return safeReply(interaction, { content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 604 |
const needed = interaction.options.getInteger('needed') || 7;
|
| 605 |
const content = `⭐▬▬▬▬▬ **FRIENDLY** ▬▬▬▬▬⭐\n🤝 Session\n🟩 I'm In\n🟥 Busy\n⭐▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬⭐\n🗳️ Needed: ${needed}\n@everyone`;
|
| 606 |
+
const msg = await safeReply(interaction, { content, fetchReply: true, allowedMentions: { parse: ['everyone'] } });
|
| 607 |
+
if (msg) {
|
| 608 |
+
await msg.react('🟩').catch(() => {});
|
| 609 |
+
await msg.react('🟥').catch(() => {});
|
| 610 |
+
storage.data.active_polls[interaction.guildId] = msg.id;
|
| 611 |
+
storage.save('active_polls');
|
| 612 |
+
}
|
| 613 |
}
|
| 614 |
|
| 615 |
if (interaction.commandName === 'leaguematch') {
|
| 616 |
+
if (!roleStorage.isWhitelisted(interaction.guildId, interaction.member)) return safeReply(interaction, { content: "❌ No Permission", flags: [MessageFlags.Ephemeral] });
|
| 617 |
const home = interaction.options.getString('home');
|
| 618 |
const away = interaction.options.getString('away');
|
| 619 |
const link = interaction.options.getString('link');
|
|
|
|
| 629 |
.addOptions(TIMEZONE_OPTIONS)
|
| 630 |
);
|
| 631 |
|
| 632 |
+
await safeReply(interaction, { content: "🌍 **Select your timezone** to finalize the match schedule:", components: [row], flags: [MessageFlags.Ephemeral] });
|
| 633 |
}
|
| 634 |
|
| 635 |
if (interaction.commandName === 'win' || interaction.commandName === 'loss' || interaction.commandName === 'draw') {
|