Skip to content

Conversation

@zoidberg77
Copy link

No description provided.

@Katakompe Katakompe added the feature request Suggest a new feature label Dec 1, 2021
@Katakompe Katakompe requested a review from PKlempe December 1, 2021 09:15
@PKlempe PKlempe linked an issue Dec 1, 2021 that may be closed by this pull request
@PKlempe PKlempe added the enhancement New feature or request label Dec 1, 2021
await message.author.send("Translation is currently unavailable(no api key)")
translator = deepl.Translator(constants.DEEPL_API_KEY)
try:
translated_text = translator.translate_text(message.content, target_lang="EN-US").text
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This task will probably take some time. Wrap it in a async with ctx.channel.typing(): so that SAM indicates that he is "writing" on the server while waiting for the result. This way the users will know that he is doing something.

And what about embedded messsages? Most of the info messages on the server are so called Embeds and a lot of times message.content will be empty. You therefore also need to iterate over message.embeds and translate the content of them as well.

except DeepLException:
await message.author.send("Translation is currently unavailable")
return
await message.author.send("Original:\n{}\n\nTranslated:\n{}".format(message.content, translated_text))
Copy link
Owner

@PKlempe PKlempe Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discord messages have a char limit of 2000 for non-Nitro and 4000 for Nitro users. By showing both the original and the translated version, this will often exceed these limits.

A better way to do this would be to create an Embed instead of a normal message. In an embed you can use markdown to create hyperlinks. This way you could simply link the message url from the original and paste the translated version into a field from the embed.

A good tool for designing embeds is this for example: https://leovoel.github.io/embed-visualizer/

zoidberg77 and others added 3 commits December 1, 2021 09:31
Co-authored-by: PKlempe <49726903+PKlempe@users.noreply.github.com>
Co-authored-by: PKlempe <49726903+PKlempe@users.noreply.github.com>
Co-authored-by: PKlempe <49726903+PKlempe@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature request Suggest a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

!translate feature

3 participants