Translates text in other languages into English. You can customize the command name by changing the "command_name" variable in the code. Just add it and enjoy π.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const translate = require('@iamtraction/google-translate');
let command_name = '?translate'; //congufire it according to your preference
const args = context.params.event.content.split(' ').slice(1).join(' ');
if (context.params.event.content.startsWith(`${command_name}`)) {
const translated = await translate(args, {to: 'en'});
console.log(translated);
let message = await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: ``,
embed: {
type: 'rich',
description: `Here is your translation hope it is accurate !`,
title: `Requested for translation .`,
fields: [
{
name: 'Translation query :',
value: `${args}`,
},
{
name: 'Translated in English as :',
value: translated.text,
},
],
author: {
name: `${context.params.event.author.username}#${context.params.event.author.discriminator}`,
icon_url: `https://cdn.discordapp.com/avatars/${context.params.event.author.id}/${context.params.event.author.avatar}.png`,
},
color: 0x00ffff,
},
});
await lib.discord.channels['@0.1.2'].messages.destroy({
message_id: `${context.params.event.id}`, // required
channel_id: `${context.params.event.channel_id}`, // required
});
}