/[sudobot]/trunk/src/events/message/MessageCreateEvent.ts
ViewVC logotype

Diff of /trunk/src/events/message/MessageCreateEvent.ts

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

revision 207 by rakin, Mon Jul 29 17:29:01 2024 UTC revision 393 by rakin, Mon Jul 29 17:29:59 2024 UTC
# Line 1  Line 1 
1    /**
2    * This file is part of SudoBot.
3    *
4    * Copyright (C) 2021-2022 OSN Inc.
5    *
6    * SudoBot is free software; you can redistribute it and/or modify it
7    * under the terms of the GNU Affero General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10    *
11    * SudoBot is distributed in the hope that it will be useful, but
12    * WITHOUT ANY WARRANTY; without even the implied warranty of
13    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14    * GNU Affero General Public License for more details.
15    *
16    * You should have received a copy of the GNU Affero General Public License
17    * along with SudoBot. If not, see <https://www.gnu.org/licenses/>.
18    */
19    
20  import BaseEvent from '../../utils/structures/BaseEvent';  import BaseEvent from '../../utils/structures/BaseEvent';
21  import { FileOptions, Message } from 'discord.js';  import { FileOptions, Message } from 'discord.js';
22  import DiscordClient from '../../client/Client';  import DiscordClient from '../../client/Client';
# Line 39  export default class MessageCreateEvent Line 58  export default class MessageCreateEvent
58                          options: args.filter(a => a[0] === '-'),                          options: args.filter(a => a[0] === '-'),
59                          isInteraction: false                          isInteraction: false
60                      } as CommandOptions;                      } as CommandOptions;
   
                     if (!await client.cooldown.start(message, options))  
                         return;  
61                                            
62                      await command.execute(client, message, options);                          await command.execute(client, message, options);    
63                  }                  }
# Line 58  export default class MessageCreateEvent Line 74  export default class MessageCreateEvent
74                  return;                  return;
75              }              }
76                            
77              const snippet = await client.snippetManager.get(message.guild!.id, cmdName);              const snippet = await client.snippetManager.getParsed(message.guild!.id, cmdName);
78    
79              if (snippet) {              if (snippet) {                
80                  await message.channel.send({                  try {
81                      content: snippet.content,                      await message.channel.send({
82                      files: snippet.files.map(name => {                          content: snippet.content.trim() === '' ? undefined : snippet.content,
83                          return {                          files: snippet.files.map(name => {
84                              name,                              return {
85                              attachment: path.resolve(__dirname, '../../../storage', name)                                  name,
86                          } as FileOptions                                  attachment: path.resolve(process.env.SUDO_PREFIX ?? path.join(__dirname, '../../..'), 'storage', name)
87                      }),                              } as FileOptions
88                  });                          }),
89                            embeds: snippet.embeds
90                        });
91                    }
92                    catch (e) {
93                        console.log(e);                    
94                    }
95    
96                  return;                  return;
97              }              }
# Line 77  export default class MessageCreateEvent Line 99  export default class MessageCreateEvent
99    
100          await client.afkEngine.start(message);          await client.afkEngine.start(message);
101      }      }
 }  
102    }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26