Advertisement
Guest User

Untitled

a guest
May 9th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. const { handleVoiceSelectMenu, handleVoiceModalsSubmit, handleVoiceButtonInteraction } = require('../interaction/temporaryChannelManager');
  2. const { handleCaptchaVerification } = require('../commands/verifySystem');
  3. const { Events } = require('discord.js');
  4. const { showPermissionPanel } = require('../interaction/permissionPanel');
  5.  
  6. module.exports = {
  7. name: Events.InteractionCreate,
  8. async execute(interaction) {
  9. try {
  10. if (interaction.isSelectMenu()) {
  11. await handleVoiceSelectMenu(interaction);
  12. return;
  13. }
  14. if (interaction.isModalSubmit()) {
  15. try {
  16. if (interaction.customId === 'captcha_modal') {
  17. await handleCaptchaVerification(interaction);
  18. } else if (interaction.customId === 'muteModal') {
  19. return;
  20. } else {
  21. await handleVoiceModalsSubmit(interaction);
  22. }
  23. } catch (error) {
  24. if (error.code === 10062) {
  25. console.log('Взаимодействие истекло');
  26. return;
  27. }
  28. console.error('Ошибка при обработке модального окна:', error);
  29. if (!interaction.replied && !interaction.deferred) {
  30. await interaction.reply({ content: '❌ Произошла ошибка при обработке формы', ephemeral: true}).catch(() => {});
  31. }
  32. }
  33. return;
  34. }
  35. if (interaction.isButton()) {
  36. console.log('Button pressed:', interaction.customId);
  37.  
  38. if (interaction.customId.startsWith('ban-') || interaction.customId.startsWith('unban-')) {
  39. await handleVoiceButtonInteraction(interaction);
  40. return;
  41. }
  42.  
  43. if (interaction.customId.startsWith('permissions_')) {
  44. if (interaction.user.id !== interaction.guild.ownerId) {
  45. return interaction.reply({
  46. content: '❌ Требуются права администратора',
  47. ephemeral: true
  48. }).catch(() => {});
  49. }
  50.  
  51. const action = interaction.customId.replace('permissions_', '');
  52.  
  53. try {
  54. await interaction.deferUpdate();
  55. switch (action) {
  56. case 'refresh':
  57. await showPermissionPanel(interaction);
  58. break;
  59. case 'close':
  60. if (interaction.message.deletable) {
  61. await interaction.message.delete().catch(() => {
  62. return interaction.editReply({ content: 'Панель закрыта', components: [], embeds: [] });
  63. });
  64. } else {
  65. await interaction.editReply({ content: 'Панель закрыта', components: [], embeds: [] });
  66. }
  67. break;
  68. }
  69. } catch (error) {
  70. console.error('Ошибка обработки кнопки разрешений:', error);
  71. if (!interaction.replied && !interaction.deferred) {
  72. await interaction.reply({ content: '❌ Ошибка при обработке действия', ephemeral: true }).catch(() => {});
  73. }
  74. }
  75. return;
  76. }
  77. return;
  78. }
  79. if (interaction.isChatInputCommand() || interaction.isContextMenuCommand()) {
  80. return;
  81. }
  82. } catch (error) {
  83. console.error('Ошибка в interactionCreate:', error);
  84. try {
  85. if (!interaction.replied && !interaction.deferred) {
  86. await interaction.reply({ content: 'Произошла ошибка при обработке команды.', ephemeral: true }).catch(() => {});
  87. }
  88. } catch (e) {
  89. console.error('Ошибка при отправке ответа об ошибке:', e);
  90. }
  91. }
  92. },
  93. };
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement