generated from nhcarrigan/template
fix: solve linter error
This commit is contained in:
@@ -13,34 +13,12 @@ import {
|
||||
EmbedBuilder,
|
||||
ActionRowBuilder,
|
||||
ButtonStyle,
|
||||
type Message,
|
||||
} from "discord.js";
|
||||
import { ids } from "../config/ids.js";
|
||||
import { logger } from "../utils/logger.js";
|
||||
|
||||
export const forwardOwnerDM = {
|
||||
data: new ContextMenuCommandBuilder().setName("Forward to Naomi").
|
||||
setType(ApplicationCommandType.Message),
|
||||
|
||||
async execute(interaction: MessageContextMenuCommandInteraction):
|
||||
Promise<void> {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
if (interaction.user.id !== ids.users.naomi) {
|
||||
await interaction.editReply("❌ Only Naomi can use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
const message = interaction.targetMessage;
|
||||
|
||||
if (message.author.id === ids.users.naomi) {
|
||||
await interaction.editReply(
|
||||
"No need to forward your own message to yourself 😄",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const naomi = await interaction.client.users.fetch(ids.users.naomi);
|
||||
const buildForwardedEmbed = (message: Message): EmbedBuilder => {
|
||||
const forwardedEmbed = new EmbedBuilder().
|
||||
setColor(0x58_65_F2).
|
||||
setTitle(`Message from ${String(message.author.tag)}!`).
|
||||
@@ -52,15 +30,42 @@ export const forwardOwnerDM = {
|
||||
+ (message.embeds.length > 0
|
||||
? `**Embeds:** ${String(message.embeds.length)}\n\n`
|
||||
: "")}
|
||||
\n${message.content !== "" || message.content !== null
|
||||
? message.content
|
||||
: "*[No text content]*"}\n\n`,
|
||||
\n${message.content}\n\n`,
|
||||
);
|
||||
|
||||
return forwardedEmbed;
|
||||
};
|
||||
const buildViewButtonFunction = (message: Message): ButtonBuilder => {
|
||||
const viewButton = new ButtonBuilder().
|
||||
setLabel("View Message").
|
||||
setURL(message.url).
|
||||
setStyle(ButtonStyle.Link);
|
||||
return viewButton;
|
||||
};
|
||||
|
||||
const data = new ContextMenuCommandBuilder().setName("Forward to Naomi").
|
||||
setType(ApplicationCommandType.Message);
|
||||
|
||||
const execute = async(interaction: MessageContextMenuCommandInteraction):
|
||||
Promise<void> => {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
if (interaction.user.id !== ids.users.naomi) {
|
||||
await interaction.editReply("❌ Only Naomi can use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
const message = interaction.targetMessage;
|
||||
if (message.author.id === ids.users.naomi) {
|
||||
await interaction.editReply(
|
||||
"No need to forward your own message to yourself 😄",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const naomi = await interaction.client.users.fetch(ids.users.naomi);
|
||||
const forwardedEmbed = buildForwardedEmbed(message);
|
||||
const viewButton = buildViewButtonFunction(message);
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
viewButton,
|
||||
@@ -82,9 +87,11 @@ export const forwardOwnerDM = {
|
||||
replyText = `${replyText} (Naomi's DMs might be closed)`;
|
||||
}
|
||||
await interaction.editReply(replyText);
|
||||
if (error instanceof Error) {
|
||||
await logger.error("operation", error);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const forwardOwnerDM = {
|
||||
data,
|
||||
execute,
|
||||
};
|
||||
|
||||
+4
-1
@@ -148,7 +148,10 @@ amari.discord.on(Events.ThreadCreate, (thread) => {
|
||||
const { bugReports, communityFeedback, featureRequests, policyIdeation }
|
||||
= ids.channels;
|
||||
if (
|
||||
![ bugReports, communityFeedback, featureRequests, policyIdeation ].includes(
|
||||
![ bugReports,
|
||||
communityFeedback,
|
||||
featureRequests,
|
||||
policyIdeation ].includes(
|
||||
thread.parent.id,
|
||||
)
|
||||
) {
|
||||
|
||||
@@ -29,4 +29,4 @@ const requestCommand = async(): Promise<void> => {
|
||||
}
|
||||
}
|
||||
};
|
||||
requestCommand();
|
||||
void requestCommand();
|
||||
|
||||
Reference in New Issue
Block a user