コード例 #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
        static public async Task LinkScoresaberWithDiscord(DiscordSocketClient discordSocketClient, SocketMessage message)
        {
            var r = new RoleAssignment(discordSocketClient);

            if (r.CheckIfDiscordIdIsLinked(message.Author.Id.ToString()))
            {
                await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Pog", $"Your Discord ID is already linked with your scoresaber, No worries {message.Author.Username}. If you want to unlink, type !bs unlink.").Build());

                await message.Channel.SendMessageAsync("Your Discord ID is already linked with your scoresaber, No worries " + message.Author.Username);

                return;
            }
            else
            {
                var ScoresaberId = message.Content.Substring(9);
                ScoresaberId = Regex.Replace(ScoresaberId, "[^0-9]", "");

                if (!ValidationExtension.IsDigitsOnly(ScoresaberId))
                {
                    await message.Channel.SendMessageAsync("Scoresaber ID is wrong");

                    return;
                }

                if (await ValidationExtension.IsDutch(ScoresaberId))
                {
                    var guildChannel = message.Channel as SocketGuildChannel;
                    if (guildChannel.Guild.Id != 505485680344956928)
                    {
                        message.Channel.SendMessageAsync("It seems that you are Dutch and trying to link your account outside the Dutch Discord. A Dutch request needs to be validated. Consider joining the Dutch Beat Saber Discord. (https://discord.gg/cH7mTyq)");
                    }
                    r.MakeRequest(message);
                }
                else
                {
                    JsonExtension.InsertJsonData("../../../GlobalAccounts.txt", message.Author.Id.ToString(), ScoresaberId);
                    await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Added user to the list", "Added " + message.Author.Id.ToString() + " with scoresaberID " + ScoresaberId + " to the global list", null, null).Build());

                    return;
                }
            }

            var moderationHelper = new GuildService(discordSocketClient, 505485680344956928);

            var user = message.Author;

            if (moderationHelper.UserHasRole(user, "Nieuwkomer"))
            {
                await moderationHelper.AddRole("Link my discord please", user);

                await moderationHelper.DeleteRole("Nieuwkomer", user);
            }
        }
コード例 #3
0
        static public async Task UnlinkScoresaberFromDiscord(DiscordSocketClient discordSocketClient, SocketMessage message)
        {
            var r = new RoleAssignment(discordSocketClient);

            if (r.CheckIfDiscordIdIsLinked(message.Author.Id.ToString()))
            {
                return;
            }
            else
            {
                await message.Channel.SendMessageAsync("", false, EmbedBuilderExtension.NullEmbed("Hmmmm?", "Your Discord does not seemed to be already linked. You can link a new scoresaber account with !bs link [ScoresaberID]").Build());
            }
        }
コード例 #4
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("➡"));
                }
            }
        }