1 |
import { BanOptions, CommandInteraction, EmojiIdentifierResolvable, GuildMember, Interaction, Message, Permissions, TextChannel, User } from 'discord.js'; |
import { BanOptions, CommandInteraction, EmojiIdentifierResolvable, FileOptions, GuildMember, Interaction, Message, Permissions, 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 EchoCommand extends BaseCommand { |
export default class EchoCommand extends BaseCommand { |
14 |
supportsInteractions: boolean = true; |
supportsInteractions: boolean = true; |
|
permissions = [Permissions.FLAGS.MANAGE_MESSAGES]; |
|
15 |
|
|
16 |
constructor() { |
constructor() { |
17 |
super('echo', 'moderation', []); |
super('echo', 'moderation', []); |
58 |
return; |
return; |
59 |
} |
} |
60 |
|
|
61 |
try { |
try { |
62 |
|
let { embeds, content: parsedContent } = parseEmbedsInString(content); |
63 |
|
|
64 |
await channel.send({ |
await channel.send({ |
65 |
content |
content: parsedContent.trim() === '' ? undefined : parsedContent, |
66 |
|
embeds, |
67 |
|
files: msg instanceof CommandInteraction ? undefined : [...msg.attachments.map(a => ({ |
68 |
|
attachment: a.proxyURL, |
69 |
|
description: a.description, |
70 |
|
name: a.name |
71 |
|
} as FileOptions)).values()] |
72 |
}); |
}); |
73 |
|
|
74 |
if (options.isInteraction) { |
if (options.isInteraction) { |
92 |
embeds: [ |
embeds: [ |
93 |
new MessageEmbed() |
new MessageEmbed() |
94 |
.setColor('#f14a60') |
.setColor('#f14a60') |
95 |
.setDescription(`Failed to send message. Maybe missing permissions?`) |
.setDescription(`Failed to send message. Maybe missing permissions or invalid embed schema?`) |
96 |
], |
], |
97 |
ephemeral: true |
ephemeral: true |
98 |
}); |
}); |