Exemple #1
0
        public async Task TrackUser(DiscordGuild g, ulong discordID, string uplayNickname, string relevantChannelName)
        {
            try
            {
                // SocketGuildUser trackedPerson = g.GetSingleUser(discordID);
                string queryR6ID = await _data.QueryMapping(discordID);

                if (queryR6ID != null)
                {
                    await g.ReplyToUser("Vas discord ucet uz sledujeme. / We are already tracking your Discord account.", relevantChannelName, discordID);

                    return;
                }

                string r6TabId = await TRNHttpProvider.GetID(uplayNickname);

                if (r6TabId == null)
                {
                    await g.ReplyToUser("Nepodarilo se nam najit vas Uplay ucet. / We failed to find your Uplay account data.", relevantChannelName, discordID);

                    return;
                }
                await _data.InsertIntoMapping(discordID, r6TabId);

                await g.ReplyToUser($"Nove sledujeme vase uspechy pod prezdivkou {uplayNickname} na platforme PC. / We now track you as {uplayNickname} on PC.", relevantChannelName, discordID);

                // Update the newly added user.

                bool ret = await Bot.Instance.UpdateOne(discordID);

                if (ret)
                {
                    // Print user's rank too.
                    Rank r = await TRNHttpProvider.GetCurrentRank(r6TabId);

                    if (r.Digits())
                    {
                        await g.ReplyToUser($"Aktualne vidime vas rank jako {r.FullPrint()}", relevantChannelName, discordID);
                    }
                    else
                    {
                        await g.ReplyToUser($"Aktualne vidime vas rank jako {r.CompactFullPrint()}", relevantChannelName, discordID);
                    }
                }
                else
                {
                    await g.ReplyToUser("Stala se chyba pri nastaven noveho ranku.", relevantChannelName, discordID);
                }
            }
            catch (RankParsingException e)
            {
                await g.ReplyToUser("Communication to the R6Tab server failed. Please try again or contact the local Discord admins.", relevantChannelName, discordID);

                await g.Reply("Pro admina: " + e.Message, relevantChannelName);
            }
        }
Exemple #2
0
        public async Task Track(string nick)
        {
            if (!await InstanceCheck())
            {
                return;
            }

            var author = (Discord.WebSocket.SocketGuildUser)Context.Message.Author;

            try
            {
                string queryR6ID = await Bot.Instance._data.QueryMapping(author.Id);

                if (queryR6ID != null)
                {
                    await ReplyAsync(author.Username + ": Vas discord ucet uz sledujeme. / We are already tracking your Discord account.");

                    return;
                }

                string r6TabId = await TRNHttpProvider.GetID(nick);

                if (r6TabId == null)
                {
                    await ReplyAsync(author.Username + ": Nepodarilo se nam najit vas Uplay ucet. / We failed to find your Uplay account data.");

                    return;
                }
                await Bot.Instance._data.InsertIntoMapping(author.Id, r6TabId);
                await ReplyAsync(author.Username + ": nove sledujeme vase uspechy pod prezdivkou " + nick + " na platforme PC. / We now track you as " + nick + " on PC.");

                // Update the newly added user.

                bool ret = await Bot.Instance.UpdateOne(author.Id);

                if (ret)
                {
                    // Print user's rank too.
                    Rank r = await TRNHttpProvider.GetCurrentRank(r6TabId);

                    if (r.Digits())
                    {
                        await ReplyAsync(author.Username + ": Aktualne vidime vas rank jako " + r.FullPrint());
                    }
                    else
                    {
                        await ReplyAsync(author.Username + ": Aktualne vidime vas rank jako " + r.CompactFullPrint());
                    }
                }
                else
                {
                    await ReplyAsync(author.Username + ": Stala se chyba pri nastaven noveho ranku.");
                }
            }
            catch (RankParsingException)
            {
                await ReplyAsync("Communication to the R6Tab server failed. Please try again or contact the local Discord admins.");

                return;
            }
        }