Advertisement
PrinceOfCookies

inter crea

Oct 29th, 2023
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. module.exports = {
  2. name: "interactionCreate",
  3. async execute(interaction, client) {
  4. if (interaction.isChatInputCommand()) {
  5. const { commands } = client;
  6. const { commandName } = interaction;
  7. const command = commands.get(commandName);
  8. if (!command) return;
  9.  
  10. try {
  11. await command.execute(interaction, client);
  12. } catch (error) {
  13. console.log(error);
  14. await interaction.reply({
  15. content: `Something went wrong while executing this command!`,
  16. ephemeral: true,
  17. });
  18. }
  19. } else if (interaction.isButton()) {
  20. const { buttons } = client;
  21. const { customId } = interaction;
  22. const button = buttons.get(customId);
  23. if (!button) return new Error('There is no code for this button');
  24.  
  25. try {
  26. await button.execute(interaction, client)
  27. } catch (error) {
  28. console.error(error)
  29. };
  30. }
  31. },
  32. };
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement