1 |
import { BanOptions, CommandInteraction, EmojiIdentifierResolvable, GuildMember, Interaction, Message, TextChannel, User } from 'discord.js'; |
import { BanOptions, CommandInteraction, EmojiIdentifierResolvable, FileOptions, GuildMember, Interaction, Message, TextChannel, User } 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'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
import CommandOptions from '../../types/CommandOptions'; |
8 |
import getMember from '../../utils/getMember'; |
import getMember from '../../utils/getMember'; |
9 |
import History from '../../automod/History'; |
import History from '../../automod/History'; |
10 |
import { fetchEmoji } from '../../utils/Emoji'; |
import { fetchEmoji } from '../../utils/Emoji'; |
11 |
|
import { parseEmbedsInString } from '../../utils/util'; |
12 |
|
|
13 |
export default class SendCommand extends BaseCommand { |
export default class SendCommand extends BaseCommand { |
14 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
57 |
} |
} |
58 |
|
|
59 |
try { |
try { |
60 |
|
let { embeds, content: parsedContent } = parseEmbedsInString(content); |
61 |
|
|
62 |
await member.send({ |
await member.send({ |
63 |
content |
content: parsedContent.trim() === '' ? undefined : parsedContent, |
64 |
|
embeds, |
65 |
|
files: msg instanceof CommandInteraction ? undefined : [...msg.attachments.map(a => ({ |
66 |
|
attachment: a.proxyURL, |
67 |
|
description: a.description, |
68 |
|
name: a.name |
69 |
|
} as FileOptions)).values()] |
70 |
}); |
}); |
71 |
|
|
72 |
if (options.isInteraction) { |
if (options.isInteraction) { |
90 |
embeds: [ |
embeds: [ |
91 |
new MessageEmbed() |
new MessageEmbed() |
92 |
.setColor('#f14a60') |
.setColor('#f14a60') |
93 |
.setDescription(`Failed to send message. Maybe missing permissions or the user has disabled DMs?`) |
.setDescription(`Failed to send message. Maybe invalid embed schema or the user has disabled DMs?`) |
94 |
], |
], |
95 |
ephemeral: true |
ephemeral: true |
96 |
}); |
}); |