Example #1
0
        public async void UseLocalAvatar(DiscordShardedClient client, string AlbumName, string ArtistName, string LastFMName)
        {
            try
            {
                trackString = ArtistName + " - " + AlbumName + Environment.NewLine + LastFMName;
                _logger.Log("Changed avatar to: " + trackString);
                //FileStream fileStream = new FileStream(GlobalVars.CoversFolder + ArtistName + " - " + AlbumName + ".png", FileMode.Open);
                FileStream fileStream = new FileStream(GlobalVars.ImageFolder + "censored.png", FileMode.Open);
                Image      image      = new Image(fileStream);
                await client.CurrentUser.ModifyAsync(u => u.Avatar = image).ConfigureAwait(false);

                fileStream.Close();

                await Task.Delay(5000).ConfigureAwait(false);

                ulong BroadcastServerID  = Convert.ToUInt64(ConfigData.Data.BaseServer);
                ulong BroadcastChannelID = Convert.ToUInt64(ConfigData.Data.FeaturedChannel);

                SocketGuild       guild   = client.GetGuild(BroadcastServerID);
                SocketTextChannel channel = guild.GetTextChannel(BroadcastChannelID);

                EmbedBuilder   builder  = new EmbedBuilder();
                SocketSelfUser SelfUser = client.CurrentUser;
                builder.WithThumbnailUrl(SelfUser.GetAvatarUrl());
                builder.AddField("Featured:", trackString);

                await channel.SendMessageAsync("", false, builder.Build()).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                _logger.LogException("UseLocalAvatar", e);
            }
        }
Example #2
0
 public HelpEmbed(SocketSelfUser selfUser)
 {
     embedBuilder  = new EmbedBuilder();
     Username      = selfUser.Username;
     UserAvatarUrl = selfUser.GetAvatarUrl();
     Commands.Add(".p | .play (название трека / ссылка)", "ищет и транслирует песню в голосовом канале");
     Commands.Add(".panel | .controlpanel", "выводит панель управления и сведения о текущим треком ");
     Commands.Add(".q | .queue", "показывает текущий плэйлист");
 }
Example #3
0
        internal static EmbedBuilder StatsBuilder(OutputFormatter formatter, SocketSelfUser me, int clanLevel, int averageMS, int tapsPerCq, int[] attackers)
        {
            var absLevel = Math.Abs(clanLevel);

            var currentBonus    = Calculator.ClanBonus(absLevel);
            var nextBonus       = Calculator.ClanBonus(absLevel + 1);
            var nextTitanLordHp = Calculator.TitanLordHp(absLevel);
            var advanceStart    = Calculator.AdvanceStart(absLevel);

            var avatar = me.GetAvatarUrl() == null ? null : new Uri(me.GetAvatarUrl());

            var builder = new EmbedBuilder
            {
                Footer = new EmbedFooterBuilder
                {
                    IconUrl = avatar,
                    Text    = me.Username + "#" + me.Discriminator
                },
                Color  = System.Drawing.Color.DarkOrange.ToDiscord(),
                Author = new EmbedAuthorBuilder
                {
                    Name = $"Displaying stats for a level {clanLevel} clan",
                },
                Timestamp = DateTime.Now
            };

            builder.AddInlineField("Current CQ", formatter.Beautify(absLevel));
            builder.AddInlineField("Current Bonus", formatter.Beautify(currentBonus) + "%");
            builder.AddInlineField("Next Bonus", formatter.Beautify(nextBonus) + "%");
            builder.AddInlineField("Next Titan Lord HP", formatter.Beautify(nextTitanLordHp));
            builder.AddInlineField("Advance start", formatter.Beautify(advanceStart * 100) + "%");
            attackers = attackers.Count() == 0 ? new int[] { 20, 30, 40, 50 } : attackers;
            builder.AddField($"Requirements per boss (assuming MS {averageMS} + {tapsPerCq} taps)", string.Join("\n", attackers.Select(num =>
            {
                var dmgpp   = nextTitanLordHp / num;
                var attacks = Calculator.AttacksNeeded(absLevel, num, averageMS, tapsPerCq);
                var dia     = Calculator.TotalAttackCost(attacks);
                return($"Attackers: {num} | Damage/person: {formatter.Beautify(dmgpp)} | Attacks: {formatter.Beautify(attacks)} | Diamonds: {formatter.Beautify(dia)}");
            })));

            return(builder);
        }
Example #4
0
 public VoteEmbed(SocketGuildUser user, LavaPlayer player, SocketSelfUser selfuser)
 {
     embedBuilder        = new EmbedBuilder();
     this.user           = user;
     _player             = player;
     Channel             = player.VoiceChannel;
     embedBuilder.Footer = new EmbedFooterBuilder
     {
         Text    = "Для просмотра плейлиста | . q",
         IconUrl = selfuser.GetAvatarUrl()
     };
 }
Example #5
0
        public async void ChangeToNewAvatar(DiscordShardedClient client, string thumbnail)
        {
            try
            {
                WebRequest  request  = WebRequest.Create(thumbnail);
                WebResponse response = await request.GetResponseAsync().ConfigureAwait(false);

                using (Stream output = File.Create(GlobalVars.ImageFolder + "newavatar.png"))
                    using (Stream input = response.GetResponseStream())
                    {
                        input.CopyTo(output);
                        if (File.Exists(GlobalVars.ImageFolder + "newavatar.png"))
                        {
                            File.SetAttributes(GlobalVars.ImageFolder + "newavatar.png", FileAttributes.Normal);
                        }

                        output.Close();
                        input.Close();
                    }

                if (File.Exists(GlobalVars.ImageFolder + "newavatar.png"))
                {
                    FileStream fileStream = new FileStream(GlobalVars.ImageFolder + "newavatar.png", FileMode.Open);
                    await client.CurrentUser.ModifyAsync(u => u.Avatar = new Image(fileStream)).ConfigureAwait(false);

                    fileStream.Close();
                }

                await Task.Delay(5000).ConfigureAwait(false);


                ulong BroadcastServerID  = Convert.ToUInt64(ConfigData.Data.BaseServer);
                ulong BroadcastChannelID = Convert.ToUInt64(ConfigData.Data.FeaturedChannel);

                SocketGuild       guild   = client.GetGuild(BroadcastServerID);
                SocketTextChannel channel = guild.GetTextChannel(BroadcastChannelID);

                EmbedBuilder   builder  = new EmbedBuilder();
                SocketSelfUser SelfUser = client.CurrentUser;
                builder.WithThumbnailUrl(SelfUser.GetAvatarUrl());
                builder.AddField("Featured:", trackString);

                await channel.SendMessageAsync("", false, builder.Build()).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                _logger.LogException("ChangeToNewAvatar", e);
            }
        }
Example #6
0
        public async Task <RestUserMessage> CreateEmbed(ISocketMessageChannel messageChannel)
        {
            embedBuilder.Author.Name    = "Выберите трек";
            embedBuilder.Author.IconUrl = selfUser.GetAvatarUrl();
            embedBuilder.Description    = PrintTracks(searchResults);
            embedBuilder.Footer.IconUrl = user.GetAvatarUrl();
            embedBuilder.Footer.Text    = "Для выбора трека нажмите на реакцию | .help";

            RestUserMessage message = await messageChannel.SendMessageAsync("", false, embedBuilder.Build());

            foreach (var item in ChooseEmojis)
            {
                await message.AddReactionAsync(item);

                Thread.Sleep(300);
            }
            return(message);
        }
        internal static LocalisedEmbedBuilder StatsBuilder(SocketSelfUser me, int clanLevel, int?avgMS = null, int?tpCQ = null, int[] attackers = null)
        {
            attackers = (attackers?.Count() ?? 0) == 0 ? new int[] { 20, 30, 40, 50 } : attackers;
            var averageMS = avgMS ?? 4000;
            var tapsPerCq = tpCQ ?? 600;

            var absLevel = Math.Abs(clanLevel);

            var currentBonus    = Calculator.ClanBonus(absLevel);
            var nextBonus       = Calculator.ClanBonus(absLevel + 1);
            var nextTitanLordHp = Calculator.TitanLordHp(absLevel);
            var advanceStart    = Calculator.AdvanceStart(absLevel);

            var builder = new LocalisedEmbedBuilder
            {
                Footer = new EmbedFooterBuilder
                {
                    IconUrl = me.GetAvatarUrl(),
                    Text    = me.Username + "#" + me.Discriminator
                },
                Color     = System.Drawing.Color.DarkOrange.ToDiscord(),
                Timestamp = DateTime.Now
            };

            builder.WithTitle(ClanStatsText.TITLE, clanLevel)
            .AddInlineField(f => f.WithName(ClanStatsText.FIELD_CQ).WithValue(absLevel))
            .AddInlineField(f => f.WithName(ClanStatsText.FIELD_BONUS_CURRENT).WithValue(BonusType.ClanDamage.ToLocalisable(currentBonus)))
            .AddInlineField(f => f.WithName(ClanStatsText.FIELD_BONUS_NEXT).WithValue(BonusType.ClanDamage.ToLocalisable(nextBonus)))
            .AddInlineField(f => f.WithName(ClanStatsText.FIELD_HP).WithValue(nextTitanLordHp))
            .AddInlineField(f => f.WithName(ClanStatsText.FIELD_ADVSTART).WithValue(advanceStart));
            LocalisedString[] rows = attackers.Select(num =>
            {
                var dmgpp   = nextTitanLordHp / num;
                var attacks = Calculator.AttacksNeeded(absLevel, num, averageMS, tapsPerCq);
                var dia     = Calculator.TotalAttackCost(attacks);
                return(new LocalisedString(ClanStatsText.FIELD_ATTACKERS_ROW, num, dmgpp, attacks, dia));
            }).ToArray();
            builder.AddField(f => f.WithName(ClanStatsText.FIELD_ATTACKERS, averageMS, tapsPerCq)
                             .WithValues("\n", rows));

            return(builder);
        }
Example #8
0
        public async void Get(Dictionary <string, object> parameters, SocketMessage e)
        {
            if (parameters.ContainsKey("avatar"))
            {
                ushort size = 128;
                if (parameters.ContainsKey("<size>"))
                {
                    ValueObject sizeValue = parameters["<size>"] as ValueObject;
                    if (sizeValue.IsInt)
                    {
                        size = (ushort)Utilities.Clamp(32, 128, sizeValue.AsInt);
                    }
                }

                SocketSelfUser bot              = DiscordHost.Instance.ThisBot;
                string         avatarUrl        = bot.GetAvatarUrl(ImageFormat.Png, size);
                string         downloadLocation = Utilities.TempFilePath(".png");
                bool           downloaded       = await TryDownloadFile(avatarUrl, downloadLocation, 4.MiB(), e.Channel);

                if (downloaded == true)
                {
                    await e.Channel.SendFileAsync(downloadLocation, $":tools: | Current Avatar at {size}x{size}");

                    File.Delete(downloadLocation);
                }
            }

            if (parameters.ContainsKey("logs"))
            {
                string dstfolder   = DateTime.UtcNow.ToString("dd_MM_yyyy_HH_mm_ss");
                string tempLogPath = Utilities.EnsurePath(Path.Combine(Utilities.TempFolder, dstfolder));
                FileLogger.Instance.CopyLogs(tempLogPath);
                string zipFile = Path.Combine(Utilities.TempFolder, $"{dstfolder}.zip");
                ZipFile.CreateFromDirectory(tempLogPath, zipFile);
                Directory.Delete(tempLogPath, true);
                await e.Channel.SendFileAsync(zipFile, $":tools: | Log Files");

                File.Delete(zipFile);
            }
        }