示例#1
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;
            }
        }
示例#2
0
 /// <summary>
 /// Inserts into the DiscordRanks internal dictionary of mapping from
 /// ids to ranks. Only call when having access to the database.
 /// </summary>
 /// <param name="discordID"></param>
 /// <param name="r"></param>
 /// <returns></returns>
 public async Task InsertIntoRanks(ulong discordID, Rank r)
 {
     // await Access.WaitAsync();
     DiscordRanks[discordID] = r;
     // Access.Release();
 }