From 85aa2a07049482a781d9d0e4805531b67b7c6b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?-=CB=8F=CB=8B=20Maple=20=CB=8A=CB=8E?= Date: Wed, 29 Nov 2023 20:47:46 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=AB=20Added=20the=20translation=20driv?= =?UTF-8?q?er=20being=20used=20as=20status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- src/bot/events/ClientReady.js | 7 +++++-- src/translations/drivers/deepl.js | 3 ++- src/translations/drivers/google_cloud.js | 3 ++- src/translations/drivers/google_search.js | 3 ++- src/translations/drivers/libretranslate.js | 3 ++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 77a06ed7..5cbe2c49 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,8 @@ module.exports = { // you must return the translated text and the source language, if it is auto, then return the detected language return {text: translated_text, from: source_language, to} - } + }, + name: "Demo module" } ``` diff --git a/src/bot/events/ClientReady.js b/src/bot/events/ClientReady.js index b25a58e9..80f3542d 100644 --- a/src/bot/events/ClientReady.js +++ b/src/bot/events/ClientReady.js @@ -1,12 +1,15 @@ //ClientReady event -const { Events } = require('discord.js'); +const { Events, ActivityType } = require('discord.js'); const { deployCommands } = require('../interactions/deploy.js'); +const translation_driver = require('../../translations/translations.js') + let verbose = false; module.exports = { name: Events.ClientReady, async execute(client) { console.log(`Invite me using: https://discord.com/api/oauth2/authorize?client_id=${client.application.id}&permissions=2684371968&scope=bot`) + client.user.setActivity(`Translating with ${translation_driver.name}.`, {type: ActivityType.Custom}); // if process.env.GUILD is set, check if the bot is in the guild if (process.env.GUILD) { @@ -140,4 +143,4 @@ async function checkCommandValidity(client) { return false; } } -} \ No newline at end of file +} diff --git a/src/translations/drivers/deepl.js b/src/translations/drivers/deepl.js index 86bd87d3..ea07488d 100644 --- a/src/translations/drivers/deepl.js +++ b/src/translations/drivers/deepl.js @@ -26,5 +26,6 @@ module.exports = { throw e; } } - } + }, + name: "Deepl" } diff --git a/src/translations/drivers/google_cloud.js b/src/translations/drivers/google_cloud.js index b432d604..ba88ed0f 100644 --- a/src/translations/drivers/google_cloud.js +++ b/src/translations/drivers/google_cloud.js @@ -32,5 +32,6 @@ module.exports = { handleAxiosErrors(res); return {text: res.data.data.translations[0].translatedText, from: res.data.data.translations[0].detectedSourceLanguage, to}; - } + }, + name: "Google translate" } diff --git a/src/translations/drivers/google_search.js b/src/translations/drivers/google_search.js index 50822437..a2a747b9 100644 --- a/src/translations/drivers/google_search.js +++ b/src/translations/drivers/google_search.js @@ -14,7 +14,8 @@ module.exports = { if (from === "zh") from = "zh-CN"; const { raw } = await translate(text, { to, from }); return { text: raw.sentences[0].trans, from: raw.src, to}; - } + }, + name: "Google translate" } // this can't be over 25 items long because of discord's slash command limit diff --git a/src/translations/drivers/libretranslate.js b/src/translations/drivers/libretranslate.js index 76faaa80..c2548039 100644 --- a/src/translations/drivers/libretranslate.js +++ b/src/translations/drivers/libretranslate.js @@ -43,5 +43,6 @@ module.exports = { handleAxiosErrors(response); return {text: response.data.translatedText, from, to}; - } + }, + name: "Libretranslate" }