public async Task ChangeNickname([Remainder] string nickname)
        {
            SocketGuildUser user    = (SocketGuildUser)Context.User;
            UserNicknames   account = UsersNicknames.GetNicknames(Context.User.Id);

            if (DateTime.Compare(DateTime.Now, account.TimeToNickChange) >= 0)
            {
                if (nickname.Length > 32)
                {
                    await Context.Channel.SendMessageAsync("Nick jest za długi. Przekroczyłeś odgórne limity Discorda.");
                }
                else
                {
                    await user.ModifyAsync(x =>
                    {
                        x.Nickname = nickname;
                    });

                    GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);

                    account.Nicknames.Add(nickname);
                    account.TimeToNickChange = DateTime.Now + TimeSpan.FromDays(guildCfg.DaysTillNextNicknameChange);

                    UsersNicknames.Save();

                    await Context.Channel.SendMessageAsync($"Pomyślnie zmieniono pseudonim. Następna zmiana będzie możliwa dopiero {account.TimeToNickChange}");
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync($"Nie możesz zmienić pseudonimu. Będziesz to mógł zrobić dopiero {account.TimeToNickChange}");
            }
        }
        public async Task IdUser(SocketGuildUser user)
        {
            string        result = "";
            UserNicknames n      = UsersNicknames.GetNicknames(user.Id);
            UserUsernames u      = UsersUsernames.GetUsernames(user.Id);

            foreach (string username in u.Usernames)
            {
                result += $"- {username}\n";

                if (result.Length > 1970)
                {
                    break;
                }
            }

            await Context.Channel.SendMessageAsync(result);

            result = "";

            foreach (string nickname in n.Nicknames)
            {
                result += $"- {nickname}\n";

                if (result.Length > 1970)
                {
                    break;
                }
            }

            await Context.Channel.SendMessageAsync(result);
        }
        public async Task <IActionResult> AddNicknames([FromBody] UserNicknames userNicknames)
        {
            await _userNickNamesValidator.ValidateAndThrowAsync(userNicknames);

            var response = await _addNicknamesCommand.ExecuteAsync(
                userNicknames.UserName,
                userNicknames.Nicknames.Distinct());

            return(Created(string.Empty, response));
        }
        public async Task AllowNickChange(SocketGuildUser user)
        {
            UserNicknames account = UsersNicknames.GetNicknames(user.Id);

            account.TimeToNickChange = DateTime.Now;

            UsersNicknames.Save();

            await Context.Channel.SendMessageAsync($"Zezwolono na zmianę nicku użytkownikowi {user.Mention}");
        }
Beispiel #5
0
        private static UserNicknames CreateUserNicknames(ulong id)
        {
            UserNicknames nicks = new UserNicknames()
            {
                ID        = id,
                Nicknames = new List <string>()
            };

            _nicknames.Add(nicks);
            Save();

            return(nicks);
        }
        public async Task ChkNick()
        {
            SocketGuildUser user    = (SocketGuildUser)Context.User;
            UserNicknames   account = UsersNicknames.GetNicknames(Context.User.Id);

            if (DateTime.Compare(DateTime.Now, account.TimeToNickChange) >= 0)
            {
                await Context.Channel.SendMessageAsync("Możesz zmienić pseudonim.");
            }
            else
            {
                await Context.Channel.SendMessageAsync($"Nie możesz zmienić pseudonimu. Będziesz to mógł zrobić dopiero {account.TimeToNickChange}");
            }
        }
Beispiel #7
0
        private static UserNicknames GetUserNicknames(ulong id)
        {
            IEnumerable <UserNicknames> result = from n in _nicknames
                                                 where n.ID == id
                                                 select n;

            UserNicknames nicks = result.FirstOrDefault();

            if (nicks == null)
            {
                nicks = CreateUserNicknames(id);
            }

            return(nicks);
        }