/[sudobot]/trunk/src/events/interaction/InteractionCreateEvent.ts
ViewVC logotype

Diff of /trunk/src/events/interaction/InteractionCreateEvent.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/src/events/interaction/InteractionCreate.ts revision 67 by rakin, Mon Jul 29 17:28:27 2024 UTC trunk/src/events/interaction/InteractionCreateEvent.ts revision 268 by rakin, Mon Jul 29 17:29:17 2024 UTC
# Line 20  export default class InteractionCreateEv Line 20  export default class InteractionCreateEv
20    
21              return;              return;
22          }          }
23            
24          if (interaction.isCommand()) {          if (interaction.isCommand() || interaction.isContextMenu()) {
25              await client.setMessage(interaction);              await client.setMessage(interaction);
26    
27              const { commandName } = interaction;              const { commandName } = interaction;
28    
29              const command = await client.commands.get(commandName);              const command = await client.commands.get(commandName);
30    
31              if (command && command.supportsInteractions) {              if (command && ((interaction.isCommand() && command.supportsInteractions) || (interaction.isContextMenu() && command.supportsContextMenu))) {
32                  const allowed = await client.auth.verify(interaction.member! as GuildMember, command);                  const allowed = await client.auth.verify(interaction.member! as GuildMember, command);
33    
34                  if (!allowed) {                  if (!allowed) {
# Line 50  export default class InteractionCreateEv Line 50  export default class InteractionCreateEv
50                      isInteraction: true                      isInteraction: true
51                  } as InteractionOptions;                  } as InteractionOptions;
52    
53                  if (!await client.cooldown.start(interaction, options))                  await command.execute(client, interaction, options);
54                      return;                  (global as any).lastCommand = commandName;
   
                 await command.run(client, interaction, options);  
55              }              }
56          }          }
57          else if (interaction.isAutocomplete()) {          else if (interaction.isAutocomplete()) {
# Line 70  export default class InteractionCreateEv Line 68  export default class InteractionCreateEv
68                      return;                      return;
69                  }                  }
70    
71                    if (!(await command.perms(client, interaction))) {
72                        return;
73                    }
74    
75                  const options = {                  const options = {
76                      cmdName: commandName,                      cmdName: commandName,
77                      options: interaction.options,                      options: interaction.options,
# Line 79  export default class InteractionCreateEv Line 81  export default class InteractionCreateEv
81                  } as AutoCompleteOptions;                  } as AutoCompleteOptions;
82    
83                  await command.autoComplete(client, interaction, options);                  await command.autoComplete(client, interaction, options);
84                    (global as any).lastCommand = commandName;
85                }
86            }
87            else {
88                if (!(global as any).commandName)
89                    return;
90    
91                await client.setMessage(interaction);
92    
93                const command = await client.commands.get((global as any).commandName);
94    
95                if (command && command.supportsInteractions) {
96                    const allowed = await client.auth.verify(interaction.member! as GuildMember, command);
97    
98                    if (!allowed) {
99                        return;
100                    }
101                    
102                    if (!(await command.perms(client, interaction))) {
103                        return;
104                    }
105    
106                    await command.default(client, interaction);
107              }              }
108          }          }
109      }      }

Legend:
Removed from v.67  
changed lines
  Added in v.268

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26