mirror of
https://github.com/artiemis/artemis.js.git
synced 2026-02-14 10:21:54 +00:00
23 lines
701 B
TypeScript
23 lines
701 B
TypeScript
import { ApplicationCommandType, ContextMenuCommandBuilder } from "discord.js";
|
|
import { defineCommand } from "..";
|
|
import { translateImpl } from "./translate";
|
|
import { abort } from "../../utils/error";
|
|
|
|
export default defineCommand({
|
|
data: new ContextMenuCommandBuilder()
|
|
.setName("Translate to English")
|
|
.setType(ApplicationCommandType.Message),
|
|
|
|
async execute(interaction) {
|
|
if (!interaction.isMessageContextMenuCommand()) return;
|
|
|
|
const text = interaction.targetMessage.content;
|
|
if (!text) abort("No text to translate");
|
|
|
|
await interaction.deferReply();
|
|
|
|
const payload = await translateImpl(text, null, "en-US");
|
|
await interaction.editReply(payload);
|
|
},
|
|
});
|