Пример #1
0
        public async Task Translate(string languageCode, [Remainder] string message)
        {
            var config = TranslateService.GetTranslateGuild(Context.Guild.Id);

            //Ensure whitelist isn't enforced unless the list is populated
            if (config.WhitelistRoles.Any())
            {
                //Check to see if the user has a whitelisted role
                if (!config.WhitelistRoles.Any(x => (Context.User as IGuildUser)?.RoleIds.Contains(x) == true))
                {
                    await ReplyAsync("You do not have enough permissions to run translations.");

                    return;
                }
            }

            var response = TranslateService.Translate(Context.Guild.Id, message, languageCode);

            if (response.ResponseResult != TranslateService.TranslateResponse.Result.Success)
            {
                return;
            }
            var embed = TranslateService.GetTranslationEmbed(response);

            if (embed == null)
            {
                return;
            }
            await ReplyAsync("", false, embed.Build());
        }