/[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 64 by rakin, Mon Jul 29 17:28:27 2024 UTC trunk/src/events/interaction/InteractionCreateEvent.ts revision 207 by rakin, Mon Jul 29 17:29:01 2024 UTC
# Line 11  export default class InteractionCreateEv Line 11  export default class InteractionCreateEv
11      }      }
12    
13      async run(client: DiscordClient, interaction: Interaction) {      async run(client: DiscordClient, interaction: Interaction) {
14          if (interaction.isCommand()) {          if (!interaction.guild || !interaction.channel || interaction.channel.type === 'DM') {
15                if (interaction.isRepliable())
16                    await interaction.reply({
17                        content: 'You cannot use this bot on DMs.',
18                        ephemeral: true
19                    });
20    
21                return;
22            }
23    
24            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 43  export default class InteractionCreateEv Line 53  export default class InteractionCreateEv
53                  if (!await client.cooldown.start(interaction, options))                  if (!await client.cooldown.start(interaction, options))
54                      return;                      return;
55    
56                  await command.run(client, interaction, options);                  await command.execute(client, interaction, options);
57                    (global as any).lastCommand = commandName;
58              }              }
59          }          }
60          else if (interaction.isAutocomplete()) {          else if (interaction.isAutocomplete()) {
# Line 60  export default class InteractionCreateEv Line 71  export default class InteractionCreateEv
71                      return;                      return;
72                  }                  }
73    
74                    if (!(await command.perms(client, interaction))) {
75                        return;
76                    }
77    
78                  const options = {                  const options = {
79                      cmdName: commandName,                      cmdName: commandName,
80                      options: interaction.options,                      options: interaction.options,
# Line 69  export default class InteractionCreateEv Line 84  export default class InteractionCreateEv
84                  } as AutoCompleteOptions;                  } as AutoCompleteOptions;
85    
86                  await command.autoComplete(client, interaction, options);                  await command.autoComplete(client, interaction, options);
87                    (global as any).lastCommand = commandName;
88                }
89            }
90            else {
91                if (!(global as any).commandName)
92                    return;
93    
94                await client.setMessage(interaction);
95    
96                const command = await client.commands.get((global as any).commandName);
97    
98                if (command && command.supportsInteractions) {
99                    const allowed = await client.auth.verify(interaction.member! as GuildMember, command);
100    
101                    if (!allowed) {
102                        return;
103                    }
104                    
105                    if (!(await command.perms(client, interaction))) {
106                        return;
107                    }
108    
109                    await command.default(client, interaction);
110              }              }
111          }          }
112      }      }

Legend:
Removed from v.64  
changed lines
  Added in v.207

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26