Brozy123 commited on
Commit
06b4d9f
·
verified ·
1 Parent(s): b500751

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +17 -2
index.js CHANGED
@@ -711,7 +711,7 @@ Tip: All commands support Discord Slash Commands (/) for a better experience!`;
711
  }
712
 
713
  if (commandName === 'lineupimage') {
714
- if (!roleStorage.isWhitelisted(message.guildId, message.member)) return message.reply("❌ No Permission");
715
  const waitMsg = await message.reply('⏳ **Generating lineup image...**');
716
  try {
717
  const lineup = getGuildLineup(message.guildId);
@@ -763,7 +763,7 @@ Tip: All commands support Discord Slash Commands (/) for a better experience!`;
763
  }
764
 
765
  if (commandName === 'managerlineup') {
766
- if (!roleStorage.isWhitelisted(message.guildId, message.member)) return message.reply("❌ No Permission");
767
  const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
768
  const row = new ActionRowBuilder().addComponents(
769
  new StringSelectMenuBuilder()
@@ -787,6 +787,21 @@ async function safeReply(interaction, options) {
787
  }
788
  }
789
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
790
  // Interaction Handler
791
  client.on('interactionCreate', async (interaction) => {
792
  // Only defer ChatInputCommands to prevent conflict with Button/Menu deferUpdate()
 
711
  }
712
 
713
  if (commandName === 'lineupimage') {
714
+ if (!roleStorage.isWhitelisted(message.guildId, message.member)) return sendNoPermission(message);
715
  const waitMsg = await message.reply('⏳ **Generating lineup image...**');
716
  try {
717
  const lineup = getGuildLineup(message.guildId);
 
763
  }
764
 
765
  if (commandName === 'managerlineup') {
766
+ if (!roleStorage.isWhitelisted(message.guildId, message.member)) return sendNoPermission(message);
767
  const formOptions = Object.keys(FORMATIONS).slice(0, 25).map(k => ({ label: k, value: k }));
768
  const row = new ActionRowBuilder().addComponents(
769
  new StringSelectMenuBuilder()
 
787
  }
788
  }
789
 
790
+ async function sendNoPermission(ctx) {
791
+ const msg = "❌ No Permission";
792
+ try {
793
+ if (ctx.isChatInputCommand || ctx.isButton || ctx.isStringSelectMenu || ctx.isUserSelectMenu) {
794
+ return await safeReply(ctx, { content: msg, flags: [MessageFlags.Ephemeral] });
795
+ } else {
796
+ const reply = await ctx.reply(msg);
797
+ setTimeout(() => {
798
+ reply.delete().catch(() => { });
799
+ ctx.delete().catch(() => { });
800
+ }, 5000);
801
+ }
802
+ } catch (e) { }
803
+ }
804
+
805
  // Interaction Handler
806
  client.on('interactionCreate', async (interaction) => {
807
  // Only defer ChatInputCommands to prevent conflict with Button/Menu deferUpdate()