Пример #1
0
        public static async Task NewTopSong(DiscordSocketClient discordSocketClient, SocketMessage message)
        {
            var r = new RoleAssignment(discordSocketClient);

            if (r.CheckIfDiscordIdIsLinked(message.Author.Id.ToString()) && message.Content.Count() == 11)
            {
                var scoresaberId = r.GetScoresaberIdWithDiscordId(message.Author.Id.ToString());

                var embedTask = await BeatSaberInfoExtension.GetNewTopSongWithScoresaberId(scoresaberId);

                await message.Channel.SendMessageAsync("", false, embedTask.Build());
            }
            else
            {
                if (message.Content.Length <= 11)
                {
                    await message.Channel.SendMessageAsync("", false,
                                                           EmbedBuilderExtension.NullEmbed("Search failed",
                                                                                           "Search value is not long enough. it should be larger than 3 characters.", null, null)
                                                           .Build());

                    return;
                }

                var username = message.Content.Substring(11);
                var id       = await BeatSaberInfoExtension.GetPlayerIdsWithUsername(username);

                var embedTask = await BeatSaberInfoExtension.GetNewRecentSongWithScoresaberId(id);

                await message.Channel.SendMessageAsync("", false, embedTask.Build());
            }
        }
Пример #2
0
        public static async Task NewSearch(DiscordSocketClient discordSocketClient, SocketMessage message)
        {
            var r = new RoleAssignment(discordSocketClient);

            if (message.Content.Contains("@"))
            {
                var discordId = message.Content.Substring(11).Replace("<", "").Replace(">", "").Replace("@", "")
                                .Replace("!", "");
                if (r.CheckIfDiscordIdIsLinked(discordId))
                {
                    var scoresaberId = r.GetScoresaberIdWithDiscordId(discordId);
                    var embedTask    = new List <EmbedBuilder>();
                    try
                    {
                        embedTask = await BeatSaberInfoExtension.GetPlayerSearchInfoEmbed(scoresaberId, message);
                    }
                    catch (Exception ex)
                    {
                        await message.Channel.SendMessageAsync("", false,
                                                               EmbedBuilderExtension.NullEmbed("Error",
                                                                                               ex.Message).Build());
                    }

                    if (embedTask.Count() == 0)
                    {
                        await message.Channel.SendMessageAsync("", false,
                                                               EmbedBuilderExtension.NullEmbed("No results",
                                                                                               "Try linking your discord and scoresaber again with like this: https://scoresaber.com/u/76561198033166451").Build());
                    }

                    foreach (var embedBuilder in embedTask)
                    {
                        await message.Channel.SendMessageAsync("", false, embedBuilder.Build());
                    }
                }
                else
                {
                    await message.Channel.SendMessageAsync("", false,
                                                           EmbedBuilderExtension.NullEmbed("Not linked yet!",
                                                                                           "Your discord is not linked yet. Type !bs link [Scoresaberlink] to link it.").Build());
                }
            }
            else if (r.CheckIfDiscordIdIsLinked(message.Author.Id.ToString()) && message.Content.Count() == 10)
            {
                var scoresaberId = r.GetScoresaberIdWithDiscordId(message.Author.Id.ToString());
                var embedTask    = await BeatSaberInfoExtension.GetPlayerSearchInfoEmbed(scoresaberId, message);

                foreach (var embedBuilder in embedTask)
                {
                    await message.Channel.SendMessageAsync("", false, embedBuilder.Build());
                }
            }
            else
            {
                if (message.Content.Substring(11).Count() == 0)
                {
                    await message.Channel.SendMessageAsync("", false,
                                                           EmbedBuilderExtension.NullEmbed("User's discord not linked",
                                                                                           "Your discord is not linked yet. Type !bs link [Scoresaberlink] to link it.", null,
                                                                                           null).Build());

                    return;
                }

                foreach (var embed in await BeatSaberInfoExtension.GetPlayer(message.Content.Substring(11)))
                {
                    var completedMessage = await message.Channel.SendMessageAsync("", false, embed.Build());

                    //await completedMessage.AddReactionAsync(new Emoji("⬅"));
                    //await completedMessage.AddReactionAsync(new Emoji("➡"));
                }
            }
        }