generated from nhcarrigan/template
fix: fix lint erorr
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
/**
|
||||
* @copyright NHCarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Teklu Abayneh
|
||||
*/
|
||||
|
||||
import {
|
||||
ContextMenuCommandBuilder,
|
||||
ApplicationCommandType,
|
||||
@@ -9,13 +15,14 @@ import {
|
||||
ButtonStyle,
|
||||
} 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),
|
||||
data: new ContextMenuCommandBuilder().setName("Forward to Naomi").
|
||||
setType(ApplicationCommandType.Message),
|
||||
|
||||
async execute(interaction: MessageContextMenuCommandInteraction) {
|
||||
async execute(interaction: MessageContextMenuCommandInteraction):
|
||||
Promise<void> {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
if (interaction.user.id !== ids.users.naomi) {
|
||||
@@ -26,47 +33,58 @@ export const forwardOwnerDM = {
|
||||
const message = interaction.targetMessage;
|
||||
|
||||
if (message.author.id === ids.users.naomi) {
|
||||
await interaction.editReply("No need to forward your own message to yourself 😄");
|
||||
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 = new EmbedBuilder().
|
||||
setColor(0x58_65_F2).
|
||||
setTitle(`Message from ${String(message.author.tag)}!`).
|
||||
setDescription(
|
||||
`${(message.attachments.size > 0
|
||||
? `**Attachments:** ${String(message.attachments.size)}
|
||||
file(s)\n\n`
|
||||
: "\n")
|
||||
+ (message.embeds.length > 0
|
||||
? `**Embeds:** ${String(message.embeds.length)}\n\n`
|
||||
: "")}
|
||||
\n${message.content !== "" || message.content !== null
|
||||
? message.content
|
||||
: "*[No text content]*"}\n\n`,
|
||||
);
|
||||
|
||||
const forwardedEmbed = new EmbedBuilder()
|
||||
.setColor(0x5865F2)
|
||||
.setTitle(`Message from ${message.author.tag}!`)
|
||||
.setDescription(
|
||||
(message.attachments.size > 0 ? `**Attachments:** ${message.attachments.size} file(s)\n\n` : "\n") +
|
||||
(message.embeds.length > 0 ? `**Embeds:** ${message.embeds.length}\n\n` : "") + "\n" +
|
||||
(message.content || "*[No text content]*") + "\n\n");
|
||||
const viewButton = new ButtonBuilder().
|
||||
setLabel("View Message").
|
||||
setURL(message.url).
|
||||
setStyle(ButtonStyle.Link);
|
||||
|
||||
const viewButton = new ButtonBuilder()
|
||||
.setLabel("View Message")
|
||||
.setURL(message.url)
|
||||
.setStyle(ButtonStyle.Link);
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(viewButton);
|
||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||
viewButton,
|
||||
);
|
||||
await naomi.send({
|
||||
embeds: [forwardedEmbed],
|
||||
files: message.attachments.map((att) => att.url),
|
||||
components: [ row ],
|
||||
embeds: [ forwardedEmbed ],
|
||||
files: message.attachments.map((att) => {
|
||||
return att.url;
|
||||
}),
|
||||
});
|
||||
|
||||
await interaction.editReply({
|
||||
content: "✅ Forwarded to your DMs!",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to forward:", error);
|
||||
|
||||
let replyText = "❌ Failed to forward message.";
|
||||
|
||||
if (error instanceof DiscordAPIError && error.code === 50007) {
|
||||
replyText += " (Naomi's DMs might be closed)";
|
||||
if (error instanceof DiscordAPIError && error.code === 50_007) {
|
||||
replyText = `${replyText} (Naomi's DMs might be closed)`;
|
||||
}
|
||||
|
||||
await interaction.editReply(replyText);
|
||||
if (error instanceof Error) {
|
||||
await logger.error("operation", error);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
+16
-14
@@ -89,12 +89,18 @@ amari.discord.once(Events.ClientReady, () => {
|
||||
scheduleJob("post progress reminders", "0 9 * * 1-5", async() => {
|
||||
await postProgressReminders(amari);
|
||||
});
|
||||
setInterval(() => {
|
||||
setInterval(
|
||||
() => {
|
||||
amari.recentlyActiveChannels = new Set<string>();
|
||||
}, 10 * 60 * 1000);
|
||||
setInterval(() => {
|
||||
},
|
||||
10 * 60 * 1000,
|
||||
);
|
||||
setInterval(
|
||||
() => {
|
||||
void checkRetroAchievements(amari);
|
||||
}, 10 * 60 * 1000);
|
||||
},
|
||||
10 * 60 * 1000,
|
||||
);
|
||||
});
|
||||
|
||||
amari.discord.on(Events.MessageCreate, (message) => {
|
||||
@@ -108,9 +114,12 @@ amari.discord.on(Events.MessageCreate, (message) => {
|
||||
amari.discord.on(Events.InteractionCreate, (interaction) => {
|
||||
void analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction });
|
||||
|
||||
if (interaction.isMessageContextMenuCommand() && interaction.commandName === "Forward to Naomi") {
|
||||
if (
|
||||
interaction.isMessageContextMenuCommand()
|
||||
&& interaction.commandName === "Forward to Naomi"
|
||||
) {
|
||||
void forwardOwnerDM.execute(interaction);
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if (interaction.isButton() && interaction.customId === "resolve") {
|
||||
@@ -139,10 +148,7 @@ 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,
|
||||
)
|
||||
) {
|
||||
@@ -172,8 +178,4 @@ amari.discord.on(Events.GuildMemberRemove, (member) => {
|
||||
});
|
||||
|
||||
await amari.discord.login(process.env.BOT_TOKEN);
|
||||
amari.discord.on(Events.MessageCreate, (message) => {
|
||||
const channelType = message.channel.type;
|
||||
console.log(`📩 [${channelType}] ${message.author.tag}: ${message.content}`);
|
||||
});
|
||||
instantiateServer(amari);
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
/**
|
||||
* @copyright NHCarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Teklu Abayneh
|
||||
*/
|
||||
|
||||
import { REST, Routes } from "discord.js";
|
||||
import { forwardOwnerDM } from "../commands/forwardToOwner.js";
|
||||
import { logger } from "../utils/logger.js";
|
||||
|
||||
const commands = [
|
||||
forwardOwnerDM.data.toJSON(),
|
||||
];
|
||||
|
||||
const commands = [ forwardOwnerDM.data.toJSON() ];
|
||||
const token = process.env.BOT_TOKEN;
|
||||
const clientId = process.env.GH_CLIENT_ID;
|
||||
|
||||
@@ -16,17 +20,13 @@ if (clientId === undefined) {
|
||||
}
|
||||
|
||||
const rest = new REST({ version: "10" }).setToken(token);
|
||||
(async() => {
|
||||
const requestCommand = async(): Promise<void> => {
|
||||
try {
|
||||
console.log("Registering GLOBAL context menu command... wait till appear everywhere.");
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationCommands(clientId),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log("Global registration sent! then check right-click on a message → Apps.");
|
||||
await rest.put(Routes.applicationCommands(clientId), { body: commands });
|
||||
} catch (error) {
|
||||
console.error("Registration failed:", error);
|
||||
if (error instanceof Error) {
|
||||
await logger.error("operation", error);
|
||||
}
|
||||
})();
|
||||
}
|
||||
};
|
||||
requestCommand();
|
||||
Reference in New Issue
Block a user