Exemple #1
0
        public void TestPickErrorPayloadDeserialization()
        {
            // Arrange
            var jsonString = "{\"errorSubtype\":\"NothingThere\"}";

            // Act
            PickError expectedPickError  = PickError.NothingThere;
            var       deserializedObject = JsonConvert.DeserializeObject <PickErrorPayload>(jsonString);

            // Assert
            Assert.Equal(expectedPickError, deserializedObject.ErrorSubtype);
        }
Exemple #2
0
        private async Task HandleErrorAsync(PickError error)
        {
            SetMemberConfig(Context.User.Id);
            var pickErrors = _pickCommandTexts[Context.User.Id]["errors"] as Dictionary <string, object>;

            var msg = error switch
            {
                PickError.LengthTooShort => pickErrors["length_too_short"].ToString(),
                PickError.TimesTooBig => pickErrors["times_too_big"].ToString(),
                _ => string.Empty
            };

            if (!string.IsNullOrEmpty(msg))
            {
                await Context.Channel.SendMessageAsync(msg);
            }
        }
    }