18 |
|
|
19 |
async run(client: DiscordClient, msg: CommandInteraction, options: InteractionOptions) { |
async run(client: DiscordClient, msg: CommandInteraction, options: InteractionOptions) { |
20 |
if (options.options.getSubcommand(true) === 'get') { |
if (options.options.getSubcommand(true) === 'get') { |
21 |
const snippet = await client.snippetManager.get(msg.guild!.id, options.options.getString('name')!); |
const snippet = await client.snippetManager.getParsed(msg.guild!.id, options.options.getString('name')!); |
22 |
|
|
23 |
if (!snippet) { |
if (!snippet) { |
24 |
await msg.reply({ |
await msg.reply({ |
29 |
return; |
return; |
30 |
} |
} |
31 |
|
|
32 |
await msg.reply({ |
try { |
33 |
content: snippet.content, |
await msg.reply({ |
34 |
files: snippet.files.map(name => { |
content: snippet.content.trim() === '' ? undefined : snippet.content, |
35 |
return { |
files: snippet.files.map(name => { |
36 |
name, |
return { |
37 |
attachment: path.resolve(__dirname, '../../../storage', name) |
name, |
38 |
} as FileOptions |
attachment: path.resolve(__dirname, '../../../storage', name) |
39 |
}), |
} as FileOptions |
40 |
}); |
}), |
41 |
|
embeds: snippet.embeds |
42 |
|
}); |
43 |
|
} |
44 |
|
catch (e) { |
45 |
|
console.log(e); |
46 |
|
await msg.reply({ content: 'Looks like that snippet is corrupted. Maybe invalid embed schema?', ephemeral: true }); |
47 |
|
} |
48 |
} |
} |
49 |
|
|
50 |
let cmdName = ''; |
let cmdName = ''; |