style: run format:apply

This commit is contained in:
2026-02-11 02:36:44 -03:00
parent 85c35021b5
commit 06926e5601
+85 -74
View File
@@ -1,89 +1,100 @@
import { ChatInputCommandInteraction, MessageCreateOptions, MessageFlags, SlashCommandBuilder, TextChannel } from "discord.js"; import {
import { Command } from "../../commands"; ChatInputCommandInteraction,
MessageCreateOptions,
MessageFlags,
SlashCommandBuilder,
TextChannel
} from 'discord.js';
import { Command } from '../../commands';
const builder = new SlashCommandBuilder() const builder = new SlashCommandBuilder()
.setName('bot-mimic') .setName('bot-mimic')
.setDescription('Makes the bot send a message') .setDescription('Makes the bot send a message')
.addStringOption(opt => .addStringOption((opt) =>
opt opt
.setName('content') .setName('content')
.setDescription('The text content of the message') .setDescription('The text content of the message')
.setRequired(false) .setRequired(false)
) )
.addAttachmentOption(opt => .addAttachmentOption((opt) =>
opt opt
.setName('attachment') .setName('attachment')
.setDescription('An attachment for the message') .setDescription('An attachment for the message')
.setRequired(false) .setRequired(false)
) )
.addStringOption(opt => .addStringOption((opt) =>
opt opt
.setName('reply') .setName('reply')
.setDescription('The message ID that the bot should reply to') .setDescription('The message ID that the bot should reply to')
.setRequired(false) .setRequired(false)
); );
const command: Command = { const command: Command = {
name: 'bot-mimic', name: 'bot-mimic',
builder: builder, builder: builder,
ownerOnly: true, ownerOnly: true,
execute: async (interaction: ChatInputCommandInteraction): Promise<void> => { execute: async (interaction: ChatInputCommandInteraction): Promise<void> => {
await interaction.deferReply({ flags: MessageFlags.Ephemeral }); await interaction.deferReply({ flags: MessageFlags.Ephemeral });
if (!interaction.channel?.isTextBased()) { if (!interaction.channel?.isTextBased()) {
await interaction.editReply('This command can only be used in a text channel.'); await interaction.editReply(
return; 'This command can only be used in a text channel.'
} );
return;
}
if (!interaction.channel.isSendable()) { if (!interaction.channel.isSendable()) {
await interaction.editReply('Channel is not sendable'); await interaction.editReply('Channel is not sendable');
return; return;
} }
const content = interaction.options.getString('content'); const content = interaction.options.getString('content');
const attachment = interaction.options.getAttachment('attachment'); const attachment = interaction.options.getAttachment('attachment');
const replyId = interaction.options.getString('reply'); const replyId = interaction.options.getString('reply');
if (!content && !attachment) { if (!content && !attachment) {
await interaction.editReply('Unable to send empty message. Specify content or attachment, or both.'); await interaction.editReply(
return; 'Unable to send empty message. Specify content or attachment, or both.'
} );
return;
}
const channel = interaction.channel as TextChannel; const channel = interaction.channel as TextChannel;
const message: MessageCreateOptions = {}; const message: MessageCreateOptions = {};
if (content) { if (content) {
message.content = content; message.content = content;
} }
if (replyId) { if (replyId) {
try { try {
const replyMessage = await channel.messages.fetch(replyId); const replyMessage = await channel.messages.fetch(replyId);
message.reply = { message.reply = {
messageReference: replyMessage.id messageReference: replyMessage.id
}; };
} catch { } catch {
await interaction.editReply('Invalid message ID for reply.'); await interaction.editReply('Invalid message ID for reply.');
return; return;
} }
} }
if (attachment) { if (attachment) {
message.files = [{ message.files = [
attachment: attachment.proxyURL, {
name: attachment.name attachment: attachment.proxyURL,
}]; name: attachment.name
} }
];
}
try { try {
await channel.send(message); await channel.send(message);
await interaction.editReply('Message sent successfully.'); await interaction.editReply('Message sent successfully.');
} catch (error) { } catch (error) {
console.error('Failed to send message:', error); console.error('Failed to send message:', error);
await interaction.editReply('Failed to send message.'); await interaction.editReply('Failed to send message.');
} }
} }
} };
export default command; export default command;