Exemplo n.º 1
0
        public async Task TrackUser(string discordUsername, string nick)
        {
            if (!(await InstanceCheck() && await OperatorCheck(Context.Message.Author.Id)))
            {
                return;
            }

            DiscordGuild guild        = Bot.Instance.guilds.byID[Context.Guild.Id];
            var          matchedUsers = guild.GetAllUsers(discordUsername);

            if (matchedUsers.Count() == 0)
            {
                await ReplyAsync("There is no user matching the Discord nickname " + discordUsername + ".");

                return;
            }

            if (matchedUsers.Count() > 1)
            {
                await ReplyAsync("Two or more users have the same matching Discord nickname. This command cannot continue.");

                return;
            }

            Discord.WebSocket.SocketGuildUser rightUser = matchedUsers.First();

            if (rightUser != null)
            {
                // We do not await this one, no need -- it should respond on its own time.
                _ = Bot.Instance.TrackUser(guild, rightUser.Id, nick, Context.Message.Channel.Name);
            }
        }
Exemplo n.º 2
0
        public async Task Manualrank(string discordUsername, string spectralRankName)
        {
            if (!(await InstanceCheck() && await OperatorCheck(Context.Message.Author.Id)))
            {
                return;
            }

            // match user from username

            DiscordGuild guild        = Bot.Instance.guilds.byID[Context.Guild.Id];
            var          matchedUsers = guild.GetAllUsers(discordUsername);

            if (matchedUsers.Count() == 0)
            {
                await ReplyAsync("There is no user matching the Discord nickname " + discordUsername + ".");

                return;
            }

            if (matchedUsers.Count() > 1)
            {
                await ReplyAsync("Two or more users have the same matching Discord nickname. This command cannot continue.");

                return;
            }

            Discord.WebSocket.SocketGuildUser rightUser = matchedUsers.First();

            // parse rank string
            Rank r = Ranking.FindRankFromSpectral(spectralRankName);

            if (r.met == Metal.Undefined)
            {
                await ReplyAsync("The inserted rank was not parsed correctly. Remember to put in the spectral name of the rank, such as D or P3.");

                return;
            }

            await ReplyAsync("Setting rank manually for the user " + discordUsername + " to rank " + r.FullPrint());
            await ReplyAsync("Keep in mind that the bot may update your rank later using new data from the R6Tab server.");

            await Bot.Instance.UpdateRoles(rightUser.Id, r);
        }