Beispiel #1
0
        public async Task AddNote(User user, [Remainder] string description)
        {
            if (!_service.IsUserModerator(Context.User.Id))
            {
                await SendUserNotEnoughRights();

                return;
            }

            const int REQUIRED_ARGUMENT_COUNT = 2;

            string[] arguments = description.Split(SPACE);

            if (arguments.Length != REQUIRED_ARGUMENT_COUNT)
            {
                await ReplyAsync("Command is not valid. Syntax: Note [userToKick] [type] [description].");
            }

            Enums.NoteTypes type;
            bool            isSuccessful = Enum.TryParse <Enums.NoteTypes>(arguments[0], out type);

            if (isSuccessful)
            {
                await ReplyAsync("UserId or NoteType is invalid. Or both.");
            }


            INote note = new Note(user.Id, arguments[1], Context.User.Id, DateTime.Now, type);
            await _service.AddNoteAsync(note);

            await ReplyAsync("Note has been successfully added to userToKick's history.");
        }