/[sudobot]/trunk/src/commands/utils/SnippetCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/utils/SnippetCommand.ts

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

revision 255 by rakin, Mon Jul 29 17:29:14 2024 UTC revision 344 by rakin, Mon Jul 29 17:29:40 2024 UTC
# Line 1  Line 1 
1  import { CommandInteraction, FileOptions, GuildMember, Interaction, Message, MessageAttachment } from 'discord.js';  import { CommandInteraction, FileOptions } from 'discord.js';
2  import BaseCommand from '../../utils/structures/BaseCommand';  import BaseCommand from '../../utils/structures/BaseCommand';
3  import DiscordClient from '../../client/Client';  import DiscordClient from '../../client/Client';
 import CommandOptions from '../../types/CommandOptions';  
4  import InteractionOptions from '../../types/InteractionOptions';  import InteractionOptions from '../../types/InteractionOptions';
 import MessageEmbed from '../../client/MessageEmbed';  
 import { download } from '../../utils/util';  
5  import path from 'path';  import path from 'path';
 import { fetchEmoji } from '../../utils/Emoji';  
6    
7  export default class AddsnippetCommand extends BaseCommand {  export default class AddsnippetCommand extends BaseCommand {
8      supportsInteractions: boolean = true;      supportsInteractions: boolean = true;
# Line 29  export default class AddsnippetCommand e Line 25  export default class AddsnippetCommand e
25                  return;                  return;
26              }              }
27    
28              await msg.reply({              try {
29                  content: snippet.content.trim() === '' ? undefined : snippet.content,                  await msg.reply({
30                  files: snippet.files.map(name => {                      content: snippet.content.trim() === '' ? undefined : snippet.content,
31                      return {                      files: snippet.files.map(name => {
32                          name,                          return {
33                          attachment: path.resolve(__dirname, '../../../storage', name)                              name,
34                      } as FileOptions                              attachment: path.resolve(__dirname, '../../../storage', name)
35                  }),                          } as FileOptions
36                  embeds: snippet.embeds                      }),
37              });                      embeds: snippet.embeds
38                    });
39                }
40                catch (e) {
41                    console.log(e);      
42                    await msg.reply({ content: 'Looks like that snippet is corrupted. Maybe invalid embed schema?', ephemeral: true });          
43                }
44          }          }
45    
46          let cmdName = '';          let cmdName = '';

Legend:
Removed from v.255  
changed lines
  Added in v.344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26