Skip to content

Commit

Permalink
🎫 Added the translation driver being used as status
Browse files Browse the repository at this point in the history
  • Loading branch information
-ˏˋ Maple ˊˎ committed Nov 29, 2023
1 parent 0f4a7eb commit 85aa2a0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
```

Expand Down
7 changes: 5 additions & 2 deletions src/bot/events/ClientReady.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -140,4 +143,4 @@ async function checkCommandValidity(client) {
return false;
}
}
}
}
3 changes: 2 additions & 1 deletion src/translations/drivers/deepl.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ module.exports = {
throw e;
}
}
}
},
name: "Deepl"
}
3 changes: 2 additions & 1 deletion src/translations/drivers/google_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 2 additions & 1 deletion src/translations/drivers/google_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/translations/drivers/libretranslate.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ module.exports = {
handleAxiosErrors(response);

return {text: response.data.translatedText, from, to};
}
},
name: "Libretranslate"
}

0 comments on commit 85aa2a0

Please sign in to comment.